Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

mysql ignore any distinct values

Tags:

linux

sql

mysql

i am trying to run a sql query which will not show distinct/duplicate values.

For example if using distinct option it would display only one unique result, but i would like to skip all detected distinct values i.e dont display distinct values

is it possible?

    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)
like image 410
krisdigitx Avatar asked Dec 27 '22 18:12

krisdigitx


2 Answers

SELECT col1 
FROM tb_col 
GROUP BY col1 
HAVING count(*) = 1
like image 53
Giann Avatar answered Dec 30 '22 08:12

Giann


Not showing duplicates at all:

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.  
like image 44
ypercubeᵀᴹ Avatar answered Dec 30 '22 08:12

ypercubeᵀᴹ