MySQL Forums
Forum List  »  General

Re: Find Column name by field value
Posted by: Peter Brawley
Date: September 20, 2014 12:59PM

select pkey, 'mainword' as column, mainword as value from tbl where mainword='hot'
union
select pkey, 'word1' as column, word1 as value from tbl where word1='hot'
union
select pkey, 'word2' as column, word2 as value from tbl where word2='hot'

To test containment rather than identity, ie to include words like 'shotclock', change <colname='hot' to <colname> like '%hot%';

Options: ReplyQuote


Subject
Written By
Posted
September 20, 2014 10:33AM
Re: Find Column name by field value
September 20, 2014 12:59PM
September 21, 2014 11:16AM
September 21, 2014 11:42AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.