现在有tab1,tab2表,tab1 :
name count
苹果 20
香蕉 12
橘子 23
汽车 10tab2:
name count
苹果 20
香蕉 12
橘子 23
我要查询出tab1表中,在tab2表没有的数据"汽车"来,应该怎么写sql语句
name count
苹果 20
香蕉 12
橘子 23
汽车 10tab2:
name count
苹果 20
香蕉 12
橘子 23
我要查询出tab1表中,在tab2表没有的数据"汽车"来,应该怎么写sql语句
insert into @t select '苹果' ,20
union all select '香蕉' ,12
union all select '橘子' ,23
union all select '汽车' ,10declare @a table(name varchar(10),[count] int)
insert into @a select '苹果' ,20
union all select '香蕉' ,12
union all select '橘子' ,23select * from @t where name not in(select [name] from @a)