Get column of a mysql entry

Posted by Xelluloid on Stack Overflow See other posts from Stack Overflow or by Xelluloid
Published on 2010-05-03T12:16:07Z Indexed on 2010/05/03 12:48 UTC
Read the original article Hit count: 253

Filed under:
|
|

Is there a possibility to get the name of the column a database entry belongs to?

Perhaps I have three columns with column names col1, col2 and col3. Now I want to select for every column the column with the maximum entry, something like this.

Select name_of_column(max(col1,col2,col3)). I know that I can ask for the name of the columns by its ordinal position in the information_schema.COLUMNS table but how do I get the ordinal position of a database entry within a table?

© Stack Overflow or respective owner

Related posts about mysql

Related posts about database