Reputation: 1901
Let's say I have the following rows in the table named Stuff:
id1: Id1, id2: Id2, name: Name, something: Something1;
id1: Id1, id2: Id2, name: Name, something: Something2;
I use the following query:
SELECT *
FROM Stuff
WHERE id1= Id1 AND id2 = Id2
GROUP BY id1, id2
It will return
Id1, Id2, Name, Something2
Is there any way for me to find what the 'something' column contained for the other rows, mainly "Something1" in this case? or an enumeration of all the values?
Upvotes: 0
Views: 53
Reputation: 125610
You can use GROUP_CONCAT
to get comma-separated list of values from column:
SELECT id1, id2, GROUP_CONCAT(something)
FROM Stuff
WHERE id1= Id1 AND id2 = Id2
GROUP BY id1, id2
Upvotes: 1