My mind is drawing a blank here, I've been away from this too long What is the best way to return a set of data like this in MySQL 4.1.x:table1:col1 = "foo"col2 = "bar"I want to return basically col1 AS col2, which of course you can't do, because damn MySQL only allows static aliases (at least in 4.1) so my result set will look like bar="foo".So what are the alternatives here? Thanks guys
4/15/2006 2:19:16 PM
i think i understand what you're asking but can't figure out why you'd need to do that. can you provide a better example of what you want to do here?
4/15/2006 3:09:20 PM
Like in PHP, where you can assign a variable to be a variable name AKA$foo="bar";$$foo = "blah";makes $bar="blah";And I'd like to do this because it would make my queries insanely more efficient, since I don't have MySQL 5 as an option and I can't use fucking views.
4/15/2006 3:27:40 PM
SELECT col2 AS x, col1 AS col2
4/15/2006 4:45:26 PM
doesnt work, that just creates a new alias called col2, not the value of col2 as the column name
4/15/2006 5:36:06 PM
This is generally called indirection, and I'm almost positive SQL doesn't support it. Furthermore, any implementation of it in multiple queries is going to be extremely inefficient. The database probably should be restructured to eliminate the need to do this, because I can't think of any valid reason for a database to be structured like that Variable columns are contrary to the function of a relational database.
4/15/2006 11:34:15 PM
yea, I came up with a solution that should be faster in scale, we'll see how it holds upThanks errybody
4/16/2006 11:01:21 PM