Link to home
Start Free TrialLog in
Avatar of itnifl
itniflFlag for Norway

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?
ASKER CERTIFIED SOLUTION
Avatar of fundacionrts
fundacionrts
Flag of Spain image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of itnifl

ASKER

I want to select dinstinctly based on the left column and not the right.
Avatar of itnifl

ASKER

You were right, in my case it was:
SELECT MIN(column1),column2 FROM table GROUP BY column1