mysql - SQL join some tables -
i have 4 tables:
user(userid,username,password)
book(id,title,author,isbn,cost)
orders(orderid,orderdate,userid)
(manytoone user
, onetomany orderitem
)
orderitem(id,quantity,totalprice,book_id, order_orderid)
(manytoone order
, manytoone book
)
i ma going retrieve title
, cost
, author
, orderid
, quantity
userid=1
here query:
select book.title, book.cost, book.author, orders.orderdate, orderitem.quantity, orderitem.totalprice book join orderitem on book.id = orderitem.id join orders on orders.orderid = orderitem.order_orderid user_id=1;
but query has no result!
select book.title, book.cost, book.author, orders.orderdate, orderitem.quantity, orderitem.totalprice book inner join orderitem on book.id = orderitem.book_id inner join orders on orders.orderid = orderitem.order_orderid user_id = 1;
Comments
Post a Comment