PostgreSQL RIGHT JOIN ERROR:语法错误在或附近" RIGHT"

时间:2016-03-08 10:22:29

标签: sql postgresql join

请告诉我这个sql有什么问题?

SELECT users_map.user_id 
FROM users_map
WHERE users_map.service_id = 1
AND users_map.service_user_id = 0
RIGHT OUTER JOIN user_data
ON users_map.user_id = user_data.user_id

1 个答案:

答案 0 :(得分:2)

WHERE子句应放在查询的末尾:

SELECT users_map.user_id 
FROM users_map
RIGHT OUTER JOIN user_data
  ON users_map.user_id = user_data.user_id
WHERE users_map.service_id = 1 AND 
      users_map.service_user_id = 0