Chenri wrote:
how do i get field name from this table

Time Stat1 Stat2 Stat3
0905 11111 11111 11111
0906 11111 00000 11111

i want to get the field name Stat1 & Stat 3 from the 0906 row which have 11111 as value

I expect the result to be
STAT1
STAT3

This is not easily done, if I understand you correctly. In general, a select statement can list the content of the columns and do calculations based on this content, but you are asking about the _name_ of the column. The name of the column is considered "meta data", it is not part of the data the rdbms is managing.


Select xxx from table_time where xxx=11111 and Time=0906;

You have two rows in your example table, and you want two rows in the result. This normally means you want one result row for each row in the table, but that is not the case here? It seems you want one row for each column with a specified value (11111)?


I suppose you could do something like this, if your version of mysql supports UNION (version 4.0.x and later):

SELECT 'STAT1' FROM tab WHERE Stat1=11111 and Time='0906'
UNION
SELECT 'STAT2' FROM tab WHERE Stat2=11111 and Time='0906'
UNION
SELECT 'STAT3' FROM tab WHERE Stat3=11111 and Time='0906'

can someone help me?

You should normalize your data.

<URL: http://dev.mysql.com/tech-resources/articles/intro-to-normalization.html >

Maybe if you explain what task you are trying to solve, someone could suggest a solution?

--
Roger


-- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]



Reply via email to