1064您的SQL语法有错误;连接3个表我在哪里有错误?

时间:2017-10-21 20:29:57

标签: mysql sql

美好的一天,我在查询中有什么变化?

'SELECT a.first_name,
       a.last_name,
       a.birth_date,
       a.email,
       a.aba_email,
       a.phone,
       a.mobile_phone,
FROM passport a
INNER JOIN USER c ON a.id=c.passport_id
INNER JOIN consultant b ON b.user_id=c.id
WHERE c.id = :user_id
  AND b.create_time BETWEEN UNIX_TIMESTAMP(DATE_FORMAT(:begin_date,"%Y-%m-%d 00:00:00")) AND UNIX_TIMESTAMP(DATE_FORMAT(:end_date,"%Y-%m-%d 23:59:59"))'

我得到了错误

enter image description here

1 个答案:

答案 0 :(得分:1)

我认为它是在mobile_phone之后的逗号,只有在其后有另一列时才需要逗号。

'SELECT a.first_name,
       a.last_name,
       a.birth_date,
       a.email,
       a.aba_email,
       a.phone,
       a.mobile_phone
FROM passport a
INNER JOIN USER c ON a.id=c.passport_id
INNER JOIN consultant b ON b.user_id=c.id
WHERE c.id = :user_id
  AND b.create_time BETWEEN UNIX_TIMESTAMP(DATE_FORMAT(:begin_date,"%Y-%m-%d 00:00:00")) AND UNIX_TIMESTAMP(DATE_FORMAT(:end_date,"%Y-%m-%d 23:59:59"))'