I am trying to run a mysql query to SELECT rows based on the ID's provided, here is the query:
$result = $wpdb->get_results($wpdb->prepare("SELECT guid FROM bicp_posts WHERE ID IN (%s)", $gallery[0]));
The $gallery[0] variable contains a string as: "1440,1439,1417"
Problem: When I execute this query it gives me only one row in result instead of 3 rows, For debugging purpose I displayed the last executed query and it shows this executed query:
SELECT guid FROM bicp_posts WHERE ID IN ('1440,1439,1417');
Notice the commas inside IN brackets are the problem as the following query gives correct results: (without commas in brackets)
SELECT guid FROM bicp_posts WHERE ID IN (1440,1439,1417);
How can I bind the string in the query such that it is without the commas like the query written right above this sentence so that I can get correct results.