itnifl
asked on
Mysql Select distinct value from one column when selecting from two columns
I am using perl to script against mysql. I want to select two columns from a table and make sure that the only columns are returned that have distinct values in one of the columns.
select distinc column1, column2 from table;
This will return a distinct combination of the two colunms, wich is not what I want. For instance:
a 1
a 2
a 5
b 1
c 3
Every row above is distinct, but I want only rows that are distinct in the first column:
a 1
b 1
c 3
Is that possible, if so how?
select distinc column1, column2 from table;
This will return a distinct combination of the two colunms, wich is not what I want. For instance:
a 1
a 2
a 5
b 1
c 3
Every row above is distinct, but I want only rows that are distinct in the first column:
a 1
b 1
c 3
Is that possible, if so how?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
You were right, in my case it was:
SELECT MIN(column1),column2 FROM table GROUP BY column1
SELECT MIN(column1),column2 FROM table GROUP BY column1
ASKER