What is the correct syntax for creating a search query in PHP for a Wordpress database table?

When creating a search query in PHP for a Wordpress database table, you need to use the $wpdb global variable to access the Wordpress database. You can use the $wpdb->prepare() function to safely prepare the SQL query and prevent SQL injection attacks. Make sure to use the %s placeholder for string values and the %d placeholder for numeric values in your search query.

global $wpdb;

$search_term = 'search term'; // Replace 'search term' with the actual search term
$query = $wpdb->prepare("SELECT * FROM {$wpdb->prefix}your_table_name WHERE column_name LIKE %s", '%' . $wpdb->esc_like($search_term) . '%');
$results = $wpdb->get_results($query);