mysql - Selecting all columns that start with XXX using a wildcard? -


i have several columns in databases similar names. how select based on word start with? here's example table layout: enter image description here

i tried selecting info particular thing (food kind in example) using

$food = "vegetable";  mysql_query("select `" . $food . " %` `foods`"); 

but didn't seem work.

any appreciated :-)

edit: apparently wasn't clear example, know column's first words. columns same , no 'food kinds' ever added or deleted. php variable there determine 1 of couple of set kinds need.

there's no way you're trying to. query first fetch column names, process them in php , build second query, that's more complex writing out names want.

or there reason query needs dynamic? table's structure change often?


Comments

Popular posts from this blog

java - SNMP4J General Variable Binding Error -

windows - Python Service Installation - "Could not find PythonClass entry" -

Determine if a XmlNode is empty or null in C#? -