读书人

看一下这段SQL哪儿错了?该如何解决

发布时间: 2012-04-15 18:39:21 作者: rapoo

看一下这段SQL哪儿错了?

SQL code
UPDATE commentSET    comment.user_id =wp_comments.user_id,    comment.comment_approved =wp_comments.comment_approved,    comment.comment_parent =wp_comments.comment_parent,    comment.comment_content =wp_comments.comment_content,    comment.comment_date =wp_comments.comment_date,    comment.comment_author_IP =wp_comments.comment_author_IP,    comment.comment_author_email =wp_comments.comment_author_email,    comment.comment_author =wp_comments.comment_authorfrom comment,wp_commentswhere comment.comment_ID = wp_comments.comment_ID


错误:#1064 - 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 'from comment,wp_comments where comment.comment_ID = wp_comments.comment_ID' at line 11

是phpmyadmin 提示的。

[解决办法]
UPDATE comment INNER JOIN wp_comments ON comment.comment_ID = wp_comments.comment_ID
SET
comment.user_id =wp_comments.user_id,
comment.comment_approved =wp_comments.comment_approved,
comment.comment_parent =wp_comments.comment_parent,
comment.comment_content =wp_comments.comment_content,
comment.comment_date =wp_comments.comment_date,
comment.comment_author_IP =wp_comments.comment_author_IP,
comment.comment_author_email =wp_comments.comment_author_email,
comment.comment_author =wp_comments.comment_author


[解决办法]
你的写法是sqlserver的
应该

UPDATE comment,wp_comments
SET
comment.user_id =wp_comments.user_id,
comment.comment_approved =wp_comments.comment_approved,
comment.comment_parent =wp_comments.comment_parent,
comment.comment_content =wp_comments.comment_content,
comment.comment_date =wp_comments.comment_date,
comment.comment_author_IP =wp_comments.comment_author_IP,
comment.comment_author_email =wp_comments.comment_author_email,
comment.comment_author =wp_comments.comment_author
where comment.comment_ID = wp_comments.comment_ID

读书人网 >Mysql

热点推荐