Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I want to select distinct values in a database. Let me run you through a quick example.

Table:

foo bar
--- ---
a   c
c   f
d   a
c   a
f   c
a   c
d   a
a   c
c   a
f   c

Right, let's say my SQL is SELECT DISTINCT foo, bar from table. These are my results:

foo bar
--- ---
a   c
c   f
d   a
c   a
f   c

However the problem is is that there are repetitions of a c / c a just that they are in a different order. I don't want to select these, I want distinct values from both columns, please help!

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
299 views
Welcome To Ask or Share your Answers For Others

1 Answer

How about using GROUP BY?

SELECT foo,bar FROM my_table GROUP BY foo,bar


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...