Jump to content

Love the SQL section, makes MySQL easier, question about DISTINCT


Recommended Posts

Hello W3Schools Forum!
This website keeps getting better. Used to I hardly ever visited it. Now it's one of my primary go-to destination points for programming information. I really do appreciate the information.
I have got a question about the DISTINCT.
I cannot get the two column format to work.
SELECT DISTINCT column_name, column_name // Can't get this one to work.
FROM table_name;
I can get the query to work with one column.
SELECT DISTINCT column_name // It works fine using just one column.
FROM table_name;


It's worth noting. I have got a GoDaddy shared hosting. GoDaddy technical support says the hosting is on one of the older machines. The highest version of PHP is PHP 5.4 on the server.


It's probably got an older version of MySQL, also. That could be the problem. I have been with GoDaddy since 2003. I am starting to look around for other hosting providers.





Link to comment
Share on other sites

When you use DISTINCT on multiple columns, the only thing that is distinct is the combination of the column's values.

If the values of each column can be "A" and "B", the query for two columns could only return a maximum of four results: AA, AB, BA and BB

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...