再会。
查询从数据库中的表中选择不同的行:
SELECT
DISTINCT
f.id_service as f_id_service,
f.id_city as f_id_city,
f.name as f_name,
f.address as f_address,
f.business as f_business,
f.web as f_web,
f.phone as f_phone,
f.id_firm as f_id_firm,
p.name as p_name
FROM Firm f left join Price p on p.id_service=f.id_service AND p.id_city=f.id_city AND p.id_firm=f.id_firm
对于导航,我使用 NOT IN:
SELECT
DISTINCT TOP 20
f.id_service as f_id_service,
f.id_city as f_id_city,
f.name as f_name,
f.address as f_address,
f.business as f_business,
f.web as f_web,
f.phone as f_phone,
f.id_firm as f_id_firm,
p.name as p_name
FROM Firm f left join Price p on p.id_service=f.id_service AND p.id_city=f.id_city AND p.id_firm=f.id_firm
WHERE
f.name
NOT IN (
SELECT DISTINCT TOP 20
f.name FROM Firm f
left join Price p on p.id_service=f.id_service AND p.id_city=f.id_city AND p.id_firm=f.id_firm
WHERE p.id_city='73041' AND p.include='1' AND p.blocked='0' AND f.blocked='0' AND p.id_group='44' AND p.id_subgroup='266'
ORDER BY f.name ASC
)
AND p.id_firm=f.id_firm AND p.id_city='73041' AND p.include='1' AND p.blocked='0'
AND f.blocked='0' AND p.id_group='44' AND p.id_subgroup='266'
ORDER BY f.name ASC
在最后一个查询中是检查f.name NOT IN
,但我需要像在第一个查询中一样检查整个字符串,而不仅仅是f.name
.
这个怎么做?