查询从表中选择Itemnumber?

时间:2013-05-13 06:43:21

标签: sql

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

1。enter image description here

,下一张表是

2。enter image description here

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

2 个答案:

答案 0 :(得分:2)

您的查询(对于SQL Server):

select *
from Inventtable i 
inner join Texttable t on t.itemNumber=i.Refkey
where i.ID<>2 and i.filename='etable'

答案 1 :(得分:0)

select distinct itemNumber from Inventtable join Texttable on itemNumber=Refkey
where ID != 2 and filename='etable'