如果下面的第一个查询返回1377行,第二个查询返回765行, 为什么第三个查询返回1806行而不是预期的1377 + 765 = 2142行?
SELECT DISTINCT item_id FROM MyTable
WHERE(COMMENTS LIKE '%Created by Upload #90323%')
ORDER BY item_id
SELECT DISTINCT item_id FROM MyTable
WHERE (COMMENTS LIKE '%Created by Upload #90324%')
ORDER BY item_id
SELECT DISTINCT item_id FROM MyTable
where (COMMENTS LIKE '%Created by Upload #90323%')
or (COMMENTS LIKE '%Created by Upload #90324%')
ORDER BY item_id
答案 0 :(得分:4)
由于DISTINCT
,两个item_id
值将具有相同的COMMENT
值。为了证明这一点,请从所有查询中删除DISTINCT
,然后将看到行数匹配。