Say I have a table like this:
ID Guess
1 50
1 30
1 20
2 40
2 35
2 25
3 60
3 15
3 25
With “ID” as an Index.
And I want a query that groups by the “ID”, and returns all the “Guess” values for each “ID” in the same row, like this:
ID Guess1 Guess2 Guess3
1 50 30 20
2 40 35 25
3 60 15 25
How do I do this?
r937
2
it is better that you do this in your application language (php or whatever)
Thank you, though for my program I kind of need to do this in SQL.
Is there no way to do this using LEFT JOINs or something like that?
r937
4
that must be an awfully anemic programming language you’re using
no, you can’t do this with left joins
if you’re on mysql, you could use GROUP_CONCAT, but that will create a single column, not three