freelance84 Posted June 14, 2010 Share Posted June 14, 2010 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 Quote Link to comment https://forums.phpfreaks.com/topic/204749-distinct-group/ Share on other sites More sharing options...
freelance84 Posted June 14, 2010 Author Share Posted June 14, 2010 OK, I've now solved this by giving adding the year to the end of the name: 'abc - 09' and then using some php to remove the ' - 09' after it has been retrieved. Would love to know if it is even possible to do it the way I started out by trying Quote Link to comment https://forums.phpfreaks.com/topic/204749-distinct-group/#findComment-1072056 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.