Home » Php » SQL Three conditions in PHP PDO

SQL Three conditions in PHP PDO

Posted by: admin February 25, 2020 Leave a comment


Im trying to use WHERE three times with a BETWEEN two numbers but it doesn’t work and can’t find it 🙁

   $pdo = DB::get()->prepare("SELECT * 
                            FROM table 
                            WHERE (city = :city 
                            AND place = :place) 
                            AND price BETWEEEN :min_amount AND :max_amount");

$pdo->execute(array(':city'             => $city ,
                    ':place'    => $place,
                    ':min_amount'           => $min_amount,
                    ':max_amount'           => $max_amount));

Error: 42000 – SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ‘BETWEEEN ? AND ?’ at line 1

How to&Answers: