开发者

mysql ignore any distinct values

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 开发者_如何学Goto 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)


SELECT col1 
FROM tb_col 
GROUP BY col1 
HAVING count(*) = 1


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.  


  select col1
  from tb_col
  group by col1
  having count(*) < 2


Try with DISTINCT it will works!

SELECT DISTINCT(col1) as d from tb_col  where col1 = '123';
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜