Hello,
I have two tables: Authors(aut_id, aut_name) and books(b_id,aut_id,b_name)
How should i write my query in oder to display the aut_name from the table aut where there are no any book names under this aut_id.
Table: Authors
-----------------
1. Taub
2. Proakis
3. Paul gray
Table: Books
---------------
1. 1. C Techniques
2. 1. Networks
3. 2. DSP
Now when i run this query, i want to show only Paul gray.
Many thanks
Select query
Moderator: General Moderators
I think your problem is solved with a JOIN.
Try if this helps you
Try if this helps you
Code: Select all
SELECT * FROM aut
LEFT JOIN book ON aut.id = book.aut_id
WHERE aut.name='Paul gray'And if you want to generalize the query so that it lists all authors that have no books associated with them, you can do this:
Code: Select all
SELECT * FROM aut
LEFT JOIN book ON aut.id = book.aut_id
WHERE book.aut_id is NULL