左连接附近需要表达式请问我的问题哪里错了

jm81lzqq  于 2021-06-21  发布在  Mysql
关注(0)|答案(2)|浏览(267)
select `tbl_users`.`username`, `tbl_users`.`users_id`, `tbl_users`.`profile_picture`, 
   (select count(users_id) from tbl_movies_comments where users_id = `tbl_users`.`users_id`) as UsersCommentsCount, 
   (select count(users_id) from tbl_movies_reviews where users_id = `tbl_users`.`users_id`) as UserReviewsCount 
left join `tbl_movies_comments` on `tbl_users`.`users_id` = `tbl_movies_comments`.`users_id` 
left join `tbl_movies_reviews` on `tbl_users`.`users_id` = `tbl_movies_reviews`.`users_id` 
group by `tbl_users`.`username`, `tbl_users`.`users_id`, `tbl_users`.`profile_picture`,  `tbl_movies_comments`.`users_id`, `tbl_movies_reviews`.`users_id`
uklbhaso

uklbhaso1#

你的陈述格式很糟糕。这就是为什么很难调试代码。。。

....

  (
    SELECT
      Count(users_id)
    FROM
      tbl_movies_reviews
    WHERE
      users_id = tbl_users.users_id
  ) AS userreviewscount

FROM yourtablename    <<<--- Missing

    left JOIN tbl_movies_comments 
        ON tbl_users.users_id = tbl_movies_comments.users_id
....

使用诸如heidisql或联机语法格式化程序/检查器之类的工具来避免这种情况

5hcedyr0

5hcedyr02#

查询中没有from子句。

SELECT ...
FROM `tbl_users`
LEFT JOIN ...

相关问题