Jump to content

Select Distinct


wipeskim

Recommended Posts

Hi,

I am doing a script with php and mysql wich i want to list the orders details such as session_id, date, username and id.

To do this i used select distinct session_id from orders

cause i have 2 orders with the same session_id but i also want to list the username, date and id.

Since i used to distinct only the session_id it will only print on the screen the session id's.

I tryed "select Distinct session_id, username, date,id from orders" but in this case since some fields has diferent values even having the same session_id it will list all the results on the table.

What i would like to do is like "select * from orders distinct session_id" , this query doesn't work but just to give an idea.

Is there anyway of using the select statement to select all the fields and distinguish the session_id so that i can avoid duplicated session id's on the results?

If someone can help me i appreciate

Many thanks to all
Link to comment
https://forums.phpfreaks.com/topic/15401-select-distinct/
Share on other sites

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.