良い一日。
データベース内のテーブルから個別の行を選択するクエリ:
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
。
これはどうやって作るの?