-- 按指定地域、类别查 declare @area int, @type int set @area = 1 set @type=2 select * from contact a where 1=1 and exists (select 1 from rl_area ra where ra.contactid=a.contactid and ra.areaid=@area) and exists (select 1 from rl_type rt where rt.contactid=a.contactid and rt.typeid=@type) ...
declare @area int, @type int
set @area = 1 set @type=2
select * from contact a
where 1=1
and exists (select 1 from rl_area ra
where ra.contactid=a.contactid and ra.areaid=@area)
and exists (select 1 from rl_type rt
where rt.contactid=a.contactid and rt.typeid=@type)
...
这个好是好,就是插入新的记录时有点麻烦