2016-07-29 45 views
0

選擇代碼我在SQL Server 2005中使用此代碼,它的工作原理。SQL Server 2000其中代碼=從

select name 
from customers 
where code = (select code from inventory where Active = 1) 

如何在SQL Server 2000中執行此操作?

+0

如果只有一個返回代碼,應該工作 –

+2

你得到什麼錯誤? –

+0

我不知道什麼是更好的,你的方法或內部聯接:'從客戶選擇c.name內部聯合庫存我在i.code = c.code其中i.active = 1'。 –

回答

1

使用IN ..With =如果有一個以上的代碼,您的查詢就會失敗

select name from customers where code in (select code from inventory where Active=1) 
+0

如果只返回一個代碼,Doesnt'=(SELECT code ...)'在sql-server 2000中工作嗎? –

+0

是的,只要返回一個代碼就可以工作 – TheGameiswar

+0

@TimSchmelter,可能是數據相關問題,與所使用的SQL Server版本無關。 – jarlh