Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.