我有点混!
当前用户的 id 存储在会话中。
我想选择与company_id
当前用户相同的所有用户。
company_id
是user
表中的一个字段。
不起作用的查询:
SELECT `all_users`.`id`, `all_users`.`username`, `all_users`.`fullname`
FROM (`user` current_user)
JOIN `company` c ON `c`.`id` = `current_user`.`company_id`
JOIN `user` all_users ON `all_users`.`company_id` = `c`.`id`
WHERE `current_user`.`id` = <<<$current_user_id>>>
错误:
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
'current_user) JOIN `company` c ON `c`.`id` = `current_user`.`company_id` JOIN `u'