我有三张表
Order表
(主键)
ID ORDER_CODE STATUS
1 jialhe001 ORDERED
2 jialhe002 ORDERED
OrderProduct表
(主键)
ID ORDER_ID QTY PROD_CODE
1 1 10 XXD
2 1 12 YYD
Product表
(主键)
PROD_CODE description price
XXD toys 12
YYD cars 10
现在我需要 product.description, product.price, order.status, orderproduct.qty这些值
需要怎么写连接查询呢?
情景:我需要客户查一个order,需要返回order里面的产品,产品描述,价格。这个order的状态,还有每样商品的数量
多谢大家。。新手HIBERNATE 不太会多连接查询
select description,price,status,qty from product,order1,orderProduct where product.prod_code=orderProduct.prod_code and order1.id=orderProduct.order_id
提个意见哈,那个order是关键字,不可以作为表名的,否则会报sql语句错误
select p.description, p.price, o.status,op.qty
from Order o, OrderProduct op, Product p
where o.id = op.order_id and op.prod_code=p.prod_code
and o.order_code='jiahe001';
嗷。。。看错了,原来你要的是hiberante配置文件的查询。。