boney alex Posted April 29, 2007 Share Posted April 29, 2007 Hi, im in the process of writing a query but Im struggling to return the results Im after. Ive got two tables, vehicle and makeandmodel, and im trying to display a distinct row with regards to the make and model. For example, two vehicles may have the same make and model, but I only want to output one of those two records. My query so far is: SELECT Vehicle.VehicleID, Vehicle.MakeModelID FROM Vehicle LEFT JOIN MakeandModel ON Vehicle.MakeModelID = MakeandModel.MakeModelID The output Im gettin at the mo is VehicleID MakeModelID 1 3 2 3 3 1 4 2 5 4 6 4 Where two vehicles have the same make and model ( vehicles 1 and 2 AND 5 and 6), I only want the first record, so does LIMIT have to be used??? Link to comment https://forums.phpfreaks.com/topic/49201-solved-distinct-problem-with-my-query/ Share on other sites More sharing options...
boney alex Posted April 29, 2007 Author Share Posted April 29, 2007 think ive sorted it, I just added a GROUP BY clause Link to comment https://forums.phpfreaks.com/topic/49201-solved-distinct-problem-with-my-query/#findComment-241100 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.