Jump to content

Need Help Using The Distinct, But Needing More Columns Than The Distinct Column


phpjayx

Recommended Posts

I've used the following

 

$sql_select = "select DISTINCT NUMBER1 from Data where check1='1' and userid='" . $param['userid'] . "' order by timestamp asc";

 

 

-----

It correctly gets the data for just the distince values from NUMBER1, but I would like to grab more data that is not necessarily distinct... like the TIMESTAMP, or even the persons name depending on how my user has entered it, they may have entered it with a first and last name or just a first name, so I only want to grab one instance of it.....

 

Thanks in advance

You could use GROUP BY

 

SELECT number1, timestamp, firstname, lastname
FROM Data
WHERE check1='1' AND userid='{$param['userid']}'
GROUP BY number1
ORDER BY timestamp 

 

However, if several people have the same number1, you will only see one of them

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.