我似乎造成了所有类型的恶作剧
使用varchar2列进行简单查询,没有什么复杂的
1)
select distinct
name AS CLUSTER_NAME
FROM xtern_app_info a RIGHT JOIN cluster_farm b
ON a.app_cluster = b.name
where a.app_cluster = 'ASLDKJASKDJFASKDJF'
ORDER BY cluster_name desc;
零行,预期
2)
select distinct
name AS CLUSTER_NAME
FROM xtern_app_info a RIGHT JOIN cluster_farm b
ON a.app_cluster = b.name
where a.app_cluster <> 'ASLDKJASKDJFASKDJF'
ORDER BY cluster_name desc;
返回224行,注意&#34; =&#34;在WHERE
3)
如果我删除226行的地方,为什么???
select distinct
name AS CLUSTER_NAME
FROM xtern_app_info a RIGHT JOIN cluster_farm b
ON a.app_cluster = b.name
--where a.app_cluster = 'ASLDKJASKDJFASKDJF'
ORDER BY cluster_name desc;
4) 你可以取代&#39; ASLDK ......&#39;任何文字,你得到相同的结果,这是疯狂的
答案 0 :(得分:3)
如Gordon所述,在第二个查询的OR
子句中添加WHERE
条件。
2)
select distinct
name AS CLUSTER_NAME
FROM xtern_app_info a RIGHT JOIN cluster_farm b
ON a.app_cluster = b.name
where a.app_cluster <> 'ASLDKJASKDJFASKDJF' OR a.app_cluster IS NULL
ORDER BY cluster_name desc;
如果我没错,那两个神秘的条目应该是NULL。