102 456 谢谢.. 解决方案 Erm 展开 | 选择 | Wrap | 行号 使用子查询来过滤那些具有889的订单ID。如果您要将其作为连接使用,则使用distinct,除非您确定订单ID和项ID不重复。 这些可以通过实现WHERE语句来完成。 =) SELECT ItemID,OrderID FROM your_table_name WHERE OrderID = 889 Hi Guys,Can you plz help me out with this query.Using a single query, I want to find out the orderIDs that have itemID 889 and then list all the itemIDs for these orderIDs.The table orderitems is like this wayorderID itemID101 889101 677102 889102 456103 974Output should be:orderID itemID101 889101 677102 889102 456Thanks.. 解决方案 Erm Expand|Select|Wrap|Line NumbersUse a subquery to filter for those order ids that have an 889. Use a distinct if you''re going to do it as a join, unless you''re sure that there is no duplication on order id and item id.these can be done by implementing the WHERE statement. =)SELECT ItemID,OrderID FROM your_table_name WHERE OrderID = 889 这篇关于根据条件选择记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 08-29 02:03