I have two tables,

table1 having a single column:

id     |   sentence(varchar 255)
1      |   I am a boy; a good boy.

and table2 having two columns:

word    |   meaning
I       |     مين
am      |     هون
a       |     أيك 
boy     |     لرقة 
good    |     اشا 

Now I want to query both tables in such a way that I will get each word with its translation.

For the sample data the query result must be:

sentence                  |    word_meaning (virtual column)
I am a boy; a good boy.   |  {"I":"مين", "am":"هون", "a":"أيك", "boy":"لرقة", "good":"اشا"}

As you can see in word_meaning column, each word has its meaning with json.


What client language are you using? That is where you need to split a sentence into "words" and where you will need to put the output back together after fetching the individual meanings. Do not try to do it in SQL.

  • I want to do it in a single query. With only using mySQL Aug 14 '16 at 5:08
  • 1
    It might be possible with a long, ugly, slow, stored procedure.
    – Rick James
    Aug 14 '16 at 6:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.