0

My table structure -

username : website

I want to select only unique websites
I have tried running this query -

SELECT DISTINCT username,website from asd  

But it selects the unique combination

example -

John    www.google.com 
Jack    www.google.com 
Tom     www.facebook.com 

Query should return
John - www.google.com
Tom - www.facebook.com

Thank you

2 Answers2

3

You can just use GROUP BY in your case:

SELECT username, website FROM asd GROUP BY website
cypryradu
  • 56
  • 3
0

When you are using DISTINCT with more then one column, then it will search for distinct among the paired columns. So the data you are getting is absolutely right.

For your requirement, please elaborate why John is needed and not Jack?

Mayank Pandeyz
  • 25,704
  • 4
  • 40
  • 59