Answer the question
In order to leave comments, you need to log in
How to get value "A" from database where WHERE is passed by variables?
Something like this table:
I'm trying to get a row with id 2, having the variables $bar and $hat. Let's say $bar = 5; $hat = 2; (as in the picture) and get far "A" from the second line. I do it like this:
$sql = $wpdb->get_var
($wpdb->prepare("SELECT far FROM table WHERE bar =%s", $bar, "AND hat = %s", $hat ));
Answer the question
In order to leave comments, you need to log in
$wpdb->prepare("SELECT far FROM table WHERE bar = %s AND hat = %s", $bar, $hat )
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question