mysql忽略任何不同的值

kri*_*itx 4 mysql sql linux

我正在尝试运行一个不会显示不同/重复值的SQL查询.

例如,如果使用distinct选项,它将只显示一个唯一的结果,但我想跳过所有检测到的不同值,即不显示不同的值

可能吗?

    select col1  d from tb_col  where col1 = '123';

col1
------
123
123


(2 rows)


select distinct col1  d from tb_col  where col1 = '123';

col1
------
123
(1 row)
Run Code Online (Sandbox Code Playgroud)

Gia*_*ann 6

SELECT col1 
FROM tb_col 
GROUP BY col1 
HAVING count(*) = 1
Run Code Online (Sandbox Code Playgroud)


ype*_*eᵀᴹ 5

根本不显示重复:

SELECT col1 AS d
FROM tb_col
GROUP BY col1
HAVING COUNT(*) = 1            --- or perhaps HAVING COUNT(*) > 1
                               --- it's not clear what you want.  
Run Code Online (Sandbox Code Playgroud)