2012-01-22, 09:48 PM
I need to select all distinct programme names from the SCHEDULED_RECORDING column BUT I also need to return a unique identifier at the same time. Confused? Join the club.
The problem is that SELECT DISTINCT works on multiple columns so the following actually produces multiple instances of the 'name' field...
The problem is the 'oid' field is always unique as it's an auto-increment and so DISTINCT is matching on that and returning each entry for the 'name' field.
All I need is one instance of each 'name' and an associated oid - I don't care which oid I get. I've tried WHERE IN and a separate SELECT as well as trying JOIN (LEFT and INNER) but at this point my SQL is very thin.
All help appreciated.
Cheers,
Brian
The problem is that SELECT DISTINCT works on multiple columns so the following actually produces multiple instances of the 'name' field...
Code:
SELECT DISTINCT oid AS _id, name FROM SCHEDULED_RECORDING
All I need is one instance of each 'name' and an associated oid - I don't care which oid I get. I've tried WHERE IN and a separate SELECT as well as trying JOIN (LEFT and INNER) but at this point my SQL is very thin.
All help appreciated.
Cheers,
Brian