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