CCH
01-29-2010, 10:43 AM
I'm trying to build a query for mySQL to pull information from a database, but my issue is that I want to pull only the first unique value using a specific field as the index.
The problem is, when I used the DISTINCT/GROUP BY trick, it returns the last unique value instead.
For example in the following database:
[ ID | Info ]
[ 10 | Data 1 ]
[ 10 | Data 2 ]
[ 12 | Data 3 ]
The output I want will be:
[ ID | Info ]
[ 10 | Data 1 ]
[ 12 | Data 3 ]
But instead I get:
[ ID | Info ]
[ 10 | Data 2 ]
[ 12 | Data 3 ]
The problem is, when I used the DISTINCT/GROUP BY trick, it returns the last unique value instead.
For example in the following database:
[ ID | Info ]
[ 10 | Data 1 ]
[ 10 | Data 2 ]
[ 12 | Data 3 ]
The output I want will be:
[ ID | Info ]
[ 10 | Data 1 ]
[ 12 | Data 3 ]
But instead I get:
[ ID | Info ]
[ 10 | Data 2 ]
[ 12 | Data 3 ]