cmd - Error with inner join mysql query -


please inner join error. done query in ms access - it's work, when in phpmyadmin or cmd - error

select zakaz.c_id, count(zakaz.c_id) [counter]     country join ((resort join hotel on resort.res_id = hotel.res_id)     join ([number] join zakaz on (number.[num_id] = zakaz.[num_id])     ,   (number.[num_id] = zakaz.[cost])) on hotel.h_id = number.[h_id])     on country.c_id = resort.c_id group zakaz.c_id; 

in mysql, square brackets ([ ]) not valid characters identifier.

in access, used enclose identifier. in mysql, use backtick characters enclose identifier needs escaped. (this allows include spaces or other characters not allowed in identifier, , allows use reserved words identifiers. in query, none of identifiers need escaped in backticks.

also, in mysql, parens aren't necessary.

the query expressed in form easier human reader decipher. example:

  select zakaz.c_id        , count(zakaz.c_id) `counter`     country     join resort       on resort.c_id = country.c_id     join hotel       on hotel.res_id = resort.res_id     join number       on number.h_id = hotel.h_id     join zakaz       on zakaz.num_id = number.num_id       , zakaz.cost   = number.num_id     group zakaz.c_id 

(it's bit of odd condition zakaz.cost needs equal number.num_id, zakaz.num_id... appears condition specified in original query.)


Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -