0

我的情况是我有一对多的关系,例如订单和订单详细信息,我需要获取具有单个订单详细信息的订单。

4

2 回答 2

0
SELECT O1.order_number
  FROM Orders AS O1
 WHERE 1 = (
            SELECT COUNT(*)
              FROM OrderDetails AS D1
             WHERE O1.order_number = D1.order_number
           );
于 2010-06-30T08:48:52.003 回答
0

怎么样:

select * 
from order
where order_number in
    (select order_number
     from order_details
     group by order_number
     having count(*) = 1)
于 2010-06-30T07:18:39.043 回答