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!

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?

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.