Query not returning rows in a table that don't have corresponding values in another [associative] ta
- by Obay
I have
Table: ARTICLES
ID | CONTENT
---------------
1 | the quick
2 | brown fox
3 | jumps over
4 | the lazy
Table: WRITERS
ID | NAME
----------
1 | paul
2 | mike
3 | andy
Table: ARTICLES_TO_WRITERS
ARTICLE_ID | WRITER_ID
-----------------------
1 | 1
2 | 2
3 | 3
To summarize, article 4 has no writer.
So when I do a "search" for articles with the word "the":
SELECT a.id, a.content, w.name
FROM articles a, writers w, articles_to_writers atw
WHERE a.id=atw.article_id AND w.id=atw.writer_id AND content LIKE '%the%'
article 4 does not show up in the result:
ID | CONTENT | NAME
-----------------------
1 | the quick | paul
How do I make article 4 still appear in the results even though it has no writers?