Jump to content

DISTINCT GROUP?


freelance84

Recommended Posts

ID    rail_name    width   length           year
1    abc           32        25             09
1    abc           33        26             09
1    abc           65        25             09
1    fac           65        65             09
1    fac           75        15             09
1    loj           56        56             10
1    abc           32        56             10

 

The above is an axample table from mysql.

 

Previously the year column did not exist and the following php was use to extract all the different rail_name's:

$query = "SELECT DISTINCT rail_name FROM rail WHERE ID=$user_id"

 

However now there are additional years this obviously doesn't work. As you can see rail_name abc now has two different years.

 

I need to be able to query the table to return DISTINCT rail_name's of different years, i.e I need a query that would return the following from the above example table:

abc  #09
fac 
loj
abc #10

 

I really am not sure where to start looking on this one so any help would be very much appreciated

Link to comment
https://forums.phpfreaks.com/topic/204749-distinct-group/
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.