Reputation: 23
The DB columns are |name|userID|lastname|UserPass|age|gender| i am building a query to select multiple results in one request
global $wpdb;
$res = $wpdb->get_results( $wpdb->prepare(
"SELECT name, lastname
FROM datatable
WHERE userID in ( %d , %d)
AND
UserPass in ( %d, %d )",
array(
$val[1],
$val[2],
$val[3],
$val[4],
)
),
ARRAY_A
);
where $val[1] and $val[2] should be uset as userID, and $val[3] and $val[4] UserPass. And i think i have problem with ordering the placeholder values and that the query is not setup properly, could use a word of advice.
Upvotes: 0
Views: 40
Reputation: 605
Try with this :
$querystr = "
SELECT name, lastname
FROM datatable
WHERE userID in ('your user ids implode with commas')
AND
UserPass in ('password string implode with commas ')
";
$result = $wpdb->get_results($querystr, OBJECT);
Upvotes: 1
Reputation: 703
This query returns all the users that match the given passwords.
<?php
global $wpdb;
$res = $wpdb->get_results( $wpdb->prepare(
"SELECT name, lastname, UserPass
FROM datatable
WHERE userID in ( %d , %d)
HAVING UserPass in ( %d, %d )",
array(
$val[1],
$val[2],
$val[3],
$val[4],
)
),
ARRAY_A
);
?>
Maybe this helps?
Upvotes: 0