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?
MySQL ServerDatabasesPerl

Avatar of undefined
Last Comment
itnifl

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
fundacionrts

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
ASKER
itnifl

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

You were right, in my case it was:
SELECT MIN(column1),column2 FROM table GROUP BY column1
Your help has saved me hundreds of hours of internet surfing.
fblack61