Home > Archive > PHP SQL > April 2006 > Re: mysql query
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
|
|
| strawberry 2006-04-25, 7:03 pm |
| 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'
LIMIT 0 , 30
| |
| Bandul 2006-04-25, 7:03 pm |
| Thanks strawberry
"strawberry" <zac.carey@gmail.com> wrote in message
news:1145980780.415994.238000@y43g2000cwc.googlegroups.com...
> 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'
> LIMIT 0 , 30
>
| |
| Bandul 2006-04-26, 3:59 am |
| Thanks for tip.:-)
See ya
"strawberry" <zac.carey@gmail.com> wrote in message
news:1145997588.139014.173090@g10g2000cwb.googlegroups.com...
>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
>
|
|
|
|
|