Jump to content

[SOLVED] Distinct problem with my query


boney alex

Recommended Posts

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

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.