日期:2014-05-17 浏览次数:20497 次
select l1.restaurantName,l2.tagname from Restaurant l1,tagsMap l2
where l1.restaurantId = l2.restaurantId and l2.tagname in('商务宴请','川湘菜','火锅','400以上')
select distinct l1.restaurantName,
stuff(( select ','+l2.tagname
from tagsMap l2
where l1.restaurantId = l2.restaurantId and
l2.tagname in('商务宴请','川湘菜','火锅','400以上')
for XML path('')
),1,1,'') as tagname
from Restaurant l1
select restaurantName,tagname
from
(
select l1.restaurantName,l2.tagname ,
COUNT(*) over(partition by l1.restaurantName) as tag_count
from Restaurant l1,tagsMap l2
where l1.restaurantId = l2.restaurantId
and l2.tagname in('商务宴请','川湘菜','火锅','400以上')
)t
where tag_count = 4