N
N
Nikolay2016-02-27 18:08:29
PHP
Nikolay, 2016-02-27 18:08:29

Why does PDO throw an error?

Request:

SELECT * FROM `companys` 
    INNER JOIN `countrys` USING(country_id) 
    INNER JOIN `prices` ON `companys`.`company_id` = `prices`.`company_id` 
    INNER JOIN `service_description` USING(description_id) 
WHERE 
    `RU` = "1" AND 
    `companys`.`security` = "YES" AND 
    SOME( 
        SELECT `price` FROM `prices` 
            INNER JOIN `service_description` USING(description_id) 
        WHERE `service_name` = "?" 
    ) > "?"

Data:
array(2) { [0]=> string(9) "dedic_min" [1]=> string(2) "10" }

Error:
Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '( SELECT `price` FROM `prices` INNER JOIN `service_d' at line 1'

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Melkij, 2016-02-28
@tryvols

What does PDO have to do with it if MySQL gives you an error?
SOME statement syntax: dev.mysql.com/doc/refman/5.7/en/any-in-some-subque...
You have rez some neither operand nor operator. The parser is naturally surprised. Judging by the location of the error, the parser thought SOME was a column name.
What did you want to get with this condition?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question