Tutorial :SQLite - sorting question


I am using the following query to display database rows in an alphabetical order:

SELECT word_id FROM table1 ORDER BY word ASC  

But I want to get values from table2, where I don't have column "word" and to sort it by column "word" which is in table1.

I want something like this:

SELECT word_id FROM table2 ORDER BY table1.word ASC  

Thank you in advance.


You must connect the two tables with a join:

SELECT t2.word_id  FROM table2 t2     , table1 t1  WHERE t2.word_id = t1.word_id  -- this is the join  ORDER BY t1.word ASC  

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Next Post »