嗨。
我正在尝试编写一个查询,以从多个订单的Customer表中返回行。
目前我正在写2个查询来解决这个问题。无论如何,我可以把它放在一个查询中?
//Get all customers
select customerID from Customer
//For each customer
select * from Orders where orderID in
(select OrderId from Customer where customerID = 123456)
and success = 1
这里是表结构
Customer table ----------------------------------------- orderID CustName CustomerID --------------------------------------- 100 test 123456 101 test 123456 Orders table ------------------------------------ pID OrderID Success ----------------------------------- 1 100 1 2 101 1
如果您发布的代码(如您的SQL)或XML或固定的表/结构,**请**在文本编辑器中突出显示这些行,然后单击“编码”按钮(101 010)上的编辑器工具栏以很好地格式化和语法突出显示它! – 2010-06-30 19:09:06
类似于你最近的http://stackoverflow.com/questions/3152224 ...你在做什么*任何*为自己思考? – gbn 2010-06-30 19:10:50
这与您几分钟前发布的问题有什么不同? – FrustratedWithFormsDesigner 2010-06-30 19:11:06