I want to fetch all the related data from a custom MySQL table using like the statement, but the query is not working.
$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'");?>
For the multiple column
, you should use the LIKE
query in the way
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%'