我的查询有问题:
SELECT
*
FROM
att
WHERE
uid = "f6c507fe-8928-4780-8b54-819611435755"
AND
item_position <> '99'
AND
category IN('CAT1','CAT2');
结果一无所获。当我删除“item_position&lt;&gt; '99'AND”时,会显示一些项目。我认为问题是UNLIKE与IN ...有一些类别为“CAT1”和item_position“99”的行。不应显示这些行。
问候!
答案 0 :(得分:3)
尝试:
SELECT
*
FROM
att
WHERE
uid = "f6c507fe-8928-4780-8b54-819611435755"
AND
(item_position <> '99' OR item_position IS NULL)
AND
category IN('CAT1','CAT2');
您提到某些行为NULL。令人讨厌的NULL值和&lt;&gt;我记得,在逻辑上往往会互相仇视。
答案 1 :(得分:0)
他在评论中将自己固定在自己身上,但这就是他最终的结果:
SELECT
*
FROM
att
WHERE
uid = "f6c507fe-8928-4780-8b54-819611435755"
AND
(item_position <> '99' OR item_position is NULL)
AND
category IN ('CAT1','CAT2');