set @q= CONCAT('SELECT columns.column_name
from table inner
join information_schema.columns
on columns.table_schema = "dbname"
and columns.table_name = "table"
and ((',
(SELECT GROUP_CONCAT(CONCAT('columns.column_name="',column_name,'"',' and table.',column_name,' = "value','"') SEPARATOR ' OR ')
FROM INFORMATION_SCHEMA.COLUMNS
WHERE table_name = 'table'),
'))');
prepare query from @q;
execute query;
Detta fungerar säkert...
Puh!
Fiol:http://sqlfiddle.com/#!2/9420c/2/2
PS:Byt ut table
med ditt tabellnamn ,dbname
med ditt db-namn och value
med ditt värde