如何修复此查询错误

时间:2014-06-14 17:16:21

标签: mysql

我通过以下查询收到此错误:

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 'ON posts.post_category_id=categories.category_id posts.post_author_id=admin.adm' at line 22

我该如何解决这个问题?

SELECT
posts.post_id,
posts.post_title,
posts.post_img,
posts.post_content,
posts.post_content_m,
posts.post_author_id,
posts.post_keywords,
posts.post_category_id,
posts.post_img,
posts.post_date,
posts.post_time,
posts.post_hit,
posts.post_comment,
posts.post_status,
posts.post_trash,
categories.category_id,
categories.category_title,
admin.admin_id,
admin.admin_name
FROM posts  JOIN categories , admin
ON posts.post_category_id=categories.category_id  posts.post_author_id=admin.admin_id
WHERE posts.post_trash='0'
ORDER BY posts.post_id

1 个答案:

答案 0 :(得分:1)

试试这个

SELECT
posts.post_id,
posts.post_title,
posts.post_img,
posts.post_content,
posts.post_content_m,
posts.post_author_id,
posts.post_keywords,
posts.post_category_id,
posts.post_img,
posts.post_date,
posts.post_time,
posts.post_hit,
posts.post_comment,
posts.post_status,
posts.post_trash,
categories.category_id,
categories.category_title,
admin.admin_id,
admin.admin_name
FROM posts INNER JOIN categories
ON posts.post_category_id=categories.category_id  
INNER JOIN admin ON
posts.post_author_id=admin.admin_id
WHERE posts.post_trash='0'
ORDER BY posts.post_id  ";
相关问题