Jump to content

Hard to explain question, possibly SELECT DISTINCT?


rollOrDie

Recommended Posts

This is quite hard to explain, but Ill give it a shot.

 

I have a table, with 3 fields. One of the fields [portId] contains a numeric value [which can be any number, however multiple records may use the same number in some cases].

 

I need to produce an SQL statement that will select another field [in this case; 'filename'], but only one for each of the numbers that I mentioned before.

 

e.g. lets say there are 2 records for '1', and 3 records for '4', I only want to retrieve the first record from '1' and the first record from '4'.

 

I think it may be possible using the "SELECT DISTINCT" command, but Im not too sure how??

 

Any help would be great!

Link to comment
Share on other sites

Oh. maybe the following SQL query will help to explain what I need. Basically it needs to be equivalent to this:

SELECT filename FROM tblPort WHERE numeric = 2 LIMIT 1

The only thing is, it needs to be executed for every numeric value [which could be anything], not just 2.

Does that help?

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.