Jump to content

[SOLVED] MySQL DISTINCT Question


Bricktop

Recommended Posts

Hi Guys and Gals,

 

I wonder if the following is possible;  I have the following query:

 

$sql = mysql_query("SELECT DISTINCT firstname, lastname, email, telephone, FROM users ORDER BY surname ASC");

 

This works great, and as there are several people entered into the DB more than once this stops them appearing more than once when the data is outputted.

 

However, I now would like to select the "ID" column from the same "USERS" table, but obviously this means that those duplicated users show up again because each ID field is a DISTINCT value.

 

Am I able to keep the above DISTINCT results but also extract the ID from them?

 

Hope this makes sense and any help greatly appreciated.

 

Thanks

Link to comment
https://forums.phpfreaks.com/topic/150324-solved-mysql-distinct-question/
Share on other sites

How about solving the actual problem and deleting the Duplicates so you don't have to worry about it?

 

How are you going to resolve which ID is the real one?

 

It's quite a long story and it's a large database with a lot of duplicate entries.  Anyone know how I can achieve the above?

 

Thanks

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.