Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQL Where ANY column equals a value

Tags:

sql

mysql

Is it possible in MySQL to select all rows where ANY column contains a specified value?

I'm trying to write a generic search function that can work without any information about a table schema.

like image 747
Brandon Wamboldt Avatar asked Oct 07 '22 19:10

Brandon Wamboldt


1 Answers

Use SHOW COLUMNS to get a list of the columns in the table and then dynamically build your query from the results.

like image 196
John Conde Avatar answered Oct 10 '22 10:10

John Conde