我有一个名为Kits的表名,其中有5列用于Book ISBN。
我已经为此编写了sql查询,但即使匹配任何单个值或多个值,我也会得到行输出,但是当所有值匹配时它应该放弃。 这是我的SQL查询:
Select *
from kits k
left
join kits_cstm kc
on k.id = kc.id_c
where '8192933563'
and '8192933567'
and '8192933568'
and '8192933564'
and '7589765432' IN (kc.isbn_book_1_c,kc.isbn_book_2_c,kc.isbn_book_3_c,kc.isbn_book_4_c,kc.isbn_book_5_c)
and kc.city_c = 'BAN'
and kc.kit_for_c = 'SCHL'
and k.deleted = 0
ORDER
BY k.kit_id DESC
答案 0 :(得分:1)
改变你喜欢的地方:
WHERE
(kc.isbn_book_1_c IN ('8192933563', '8192933567', '8192933568', '8192933564', '7589765432') AND
kc.isbn_book_2_c IN ('8192933563', '8192933567', '8192933568', '8192933564', '7589765432') AND
kc.isbn_book_3_c IN ('8192933563', '8192933567', '8192933568', '8192933564', '7589765432') AND
kc.isbn_book_4_c IN ('8192933563', '8192933567', '8192933568', '8192933564', '7589765432') AND
kc.isbn_book_5_c IN ('8192933563', '8192933567', '8192933568', '8192933564', '7589765432') )
AND ( kc.isbn_book_1_c != kc.isbn_book_2_c != kc.isbn_book_3_c != kc.isbn_book_4_c != kc.isbn_book_5_c )
AND sam_kits_cstm.city_c='BAN'
AND sam_kits_cstm.kit_for_c='SCHL'
AND sam_kits.deleted=0