根据条件选择记录 [英] selecting records on basis of condition
问题描述
大家好,
你可以帮我解决这个问题。
使用单个查询,我想找出来具有itemID 889的orderID,然后列出这些orderID的所有itemID。
表orderitems就是这样的
orderID itemID
101 889
101 677
102 889
102 456
103 974
输出应该是:
orderID itemID
101 889
101 677
102 889 >
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 way
orderID itemID
101 889
101 677
102 889
102 456
103 974
Output should be:
orderID itemID
101 889
101 677
102 889
102 456
Thanks..解决方案Erm
Expand|Select|Wrap|Line Numbers
Use 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
这篇关于根据条件选择记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文