c# - Getting specific column name of a table -
i working on project , got stuck query in want specific column name of table value "no."
i have table name subscription , has 4 fields; id(integer
), email(varchar
), sms(varchar
), phone(varchar
) , email, sms , phone field have values either 'yes' or 'no'.
now want retrieve name of columns has value 'no'. want execute query in mysql.
i have tried following query returning me complete row wherever there 1 occurence of 'no':
select * test.subscription 'no' in (email,sms,phone);
like have these 2 rows want select column name value='no' , id=1
how cheap , cheerful using case statement like:
select id, 'colname' = case when email = 'no' 'email' end, 'colname2' = case when sms = 'no' 'sms' end, 'colname3' = case when phone = 'no' 'phone' end subscription id = 2
Comments
Post a Comment