1

我有两个表 1.Inventtable 和 2.Texttable

1.在此处输入图像描述

下一张桌子是

2.在此处输入图像描述

我需要从第二个表中选择项目编号,其中 ID!=2 和文件名 =etable 在 Inventtable.how 中为此编写查询

4

2 回答 2

2

您的查询(对于 SQL Server):

select *
from Inventtable i 
inner join Texttable t on t.itemNumber=i.Refkey
where i.ID<>2 and i.filename='etable'
于 2013-05-13T06:47:36.380 回答
0
select distinct itemNumber from Inventtable join Texttable on itemNumber=Refkey
where ID != 2 and filename='etable'
于 2013-05-13T06:58:46.787 回答