Now, I need to get a list of ownership status of each car for each person. The catch is that I need to have them each in their own column (not CONCATed or GROUP_CONCATed into one column) and I'm trying to avoid doing a COUNT(*) on the Cars table.

So, basicaly, I need to convert the rows of the Cars table into columns in this results table.

Is this even possible?

r937
—
2012-09-24T02:14:27Z —
#2

yeah, it's possible, but it's ugly and clumsy in sql

please explain why it's so hard for you to do this in your application language (php or whatever), which is where cosmetic re-arranging of query results should be taking place...

epp_b
—
2012-09-24T04:20:42Z —
#3

Well, yes, of course I can do this in PHP, but I figured it would be more eloquent and efficient with MySQL.

Also, curiosity

guelphdad
—
2012-09-24T13:19:42Z —
#4

it is the opposite, harder to do in sql, easier to do in the front end application. As r937 says, that's where cosmetic changes to the data belong.

epp_b
—
2012-09-24T14:42:10Z —
#5

Okeydokey.

epp_b
—
2012-09-25T21:50:15Z —
#6

...but just to the point of curiosity, how would one go about doing this within MySQL anyway?

squeal
—
2012-09-26T12:23:58Z —
#7

It's called a PIVOT TABLE query. Google for that and you should be able to find both examples of such queries, and further evidence in support of why it's often wiser to handle this at the application level.

Mittineague
—
2014-09-19T02:29:20Z —
#8

This topic is now archived. It is frozen and cannot be changed in any way.