查询在where子句中包含多个AND的IN操作符


Wordpress query for IN operator with multiple AND in where clause

我需要一个带有多个AND IN where子句的IN操作符的WordPress查询。

$query="SELECT  event FROM $wpdb->prifix.wp_rsvpmaker rsvp WHERE user_id IN ($format) AND event != %d
UNION ALL 
SELECT eventid
FROM $wpdb->prifix.wp_payment_event WHERE pay_user_id IN($format) AND eventid !=%d";
$value[]=$usersRegisteFrOtherEvents;
$value[]=$eventid;
$value[]=$usersRegisteFrOtherEvents;
$value[]=$eventid;
$eventIDs = $wpdb->get_results($wpdb->prepare($query,$value),ARRAY_A);

尝试使用此代码,确保在传递给prepare语句时数组中的所有占位符都是正确的:

 $how_many = count($usersRegisteFrOtherEvents);
 $placeholders = array_fill(0, $how_many, '%d');
 $format = implode(', ', $placeholders);