|
Posted by strawberry on 04/25/06 23:39
I think it's right, however, if someone buys the same book twice, the
title will show up twice in this result. You would need to modify the
query like this...
SELECT title
FROM orders, customers, order_items
LEFT JOIN books ON books.isbn = order_items.isbn
WHERE orders.customerid = customers.customerid
AND order_items.orderid = orders.orderid
AND customers.name = 'John'
GROUP BY title
LIMIT 0 , 30
Incidentally, to solve this kind of thing yourself, just build up the
query slowly, bit by bit. Begin with something like;
SELECT * FROM orders,customers;
and see where it gets you
[Back to original message]
|