使用连接的简单查询出现错误。
我的查询:
SELECT users_sessions.user_id AS users_sessions_user_id,
users.last_name AS users_last_name,
users.first_name AS users_first_name
FROM prefix_users_sessions AS users_sessions,
prefix_users AS users INNER JOIN
users_sessions
ON users.id = users_sessions.user_id
我的错误:
SQLSTATE [42000]:语法错误或访问冲突:1066 不是唯一的表/别名:'users_sessions'
我不明白这个消息......我看不出别名在哪里使用更多。
谁能帮我解决这个问题?
提前感谢您的帮助。
- 解决了 -
好的查询如下:
SELECT users_sessions.id AS users_sessions_id,
users_sessions.user_id AS users_sessions_user_id,
users.lastname AS users_lastname, users.firstname AS
users_firstname
FROM prefix_users_sessions AS users_sessions
JOIN prefix_users AS users ON users.id = users_sessions.user_id