首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > Mysql >

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

2012-04-15 
看一下这段SQL哪儿错了?SQL codeUPDATE commentSETcomment.user_id wp_comments.user_id,comment.comment

看一下这段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

热点排行