我想使用类似的语句从自定义MySQL表中获取所有相关数据,但查询无法正常工作。
$final_search = "$name $email $subject $hobby";
// this adds the prefix which is set by the user upon instillation of wordpress
$table_name = $wpdb->prefix . "credofy_contact_form";
// this will get the data from your table
$retrieve_data = $wpdb->get_results( "SELECT your_name, your_email, your_phone, your_hobby FROM $table_name WHERE your_name, your_email, your_phone, your_hobby LIKE '$final_search'");?>
答案 0 :(得分:0)
对于多个column
,您应该以这种方式使用LIKE
查询
SELECT your_name, your_email, your_phone, your_hobby
FROM table_name
WHERE your_name LIKE '%keyword%'
OR your_email LIKE '%keyword%'
OR your_phone LIKE '%keyword%'
OR your_hobby LIKE '%keyword%'