SQLite - Query involving 2 tables

I want to select a row from a specific table and order the results based on another table.

Here are my tables:

lang1_words:
word_id - word

statuses:
word_id - status

      

In each table, word_id matches the value in the other table.

Here is my request:

SELECT statuses.word_id FROM statuses, lang1_words
WHERE statuses.status >= 0
ORDER BY lang1_words.word ASC

      

But it returns more than 1 row of the same word_id and the results are not sorted alphabetically.

What is the problem with my request and how can I achieve my goal?

Thanks.

+1


a source to share


1 answer


You need to join two tables, one way to do it:



SELECT statuses.word_id FROM
statuses JOIN lang1_words ON statuses.word_id = lang1_words.word_id
WHERE statuses.status >= 0
ORDER BY lang1_words.word ASC

      

+7


a source







All Articles