1

Suppose you have 2 tables. Book(TITLE) and Subject(IDSUBJECT, title) where title in subject references to title in book. What's the query to find all the books that are not liked to a subject?

GMB
  • 195,563
  • 23
  • 62
  • 110
Tomoko
  • 21
  • 1
  • Have a look here: https://stackoverflow.com/questions/14253994/selecting-all-fields-except-only-one-field-in-mysql/14254068 – Tiago Mateus Jun 22 '20 at 22:36
  • Note that it would be unlikely to relate tables in this way; it's possible for two books to have the same title. – Strawberry Jun 23 '20 at 06:54

1 Answers1

0

Use not exists:

select b.*
from books b
where not exists (select 1 from subject s where s.title = b.title)
GMB
  • 195,563
  • 23
  • 62
  • 110