On 29/09/15 13:01, Richard Reina wrote:
If I have three simple tables: mysql> select * from customer; +----+--------+ | ID | NAME | +----+--------+ | 1 | Joey | | 2 | Mike | | 3 | Kellie | +----+--------+ 3 rows in set (0.00 sec) mysql> select * from fruit; +----+---------+ | ID | NAME | +----+---------+ | 1 | Apples | | 2 | Grapes | | 3 | Oranges | | 4 | Kiwis | +----+---------+ 4 rows in set (0.00 sec) mysql> select * from purchases; +----+---------+----------+ | ID | CUST_ID | FRUIT_ID | +----+---------+----------+---- | 2 | 3 | 2 | | 3 | 1 | 4 | | 4 | 1 | 2 | | 5 | 2 | 1 | +----+---------+----------+---- I am having trouble understanding a relational query. How can I select those fruits that Joey has not purchased?
I think you are going to want to use a "LEFT JOIN" using "purchases" as the common table to join with a WHERE purchases.FRUIT_ID IS NULL
-- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/mysql