INSERT INTO mySQL程序

时间:2012-07-25 12:42:20

标签: mysql insert procedure

在MySQL中插入INTO>

这是程序代码的一部分:

if ParentList is null then

        set @sql=concat('insert into ', table_name, tabSave, '(md5Id, CommentsId, Parent, Content, UserId, Title, Nick) ',
        'values(', @md5Id, ', ', CommentsId, ', null, \'', Content, '\'' ,UserId,',',Title,',',Nick, ')');
else
    set @sql=concat('insert into ', table_name, tabSave, '(md5Id, CommentsId, Parent, Content, UserId, Title, Nick) ',
        'values(', @md5Id, ', ', CommentsId, ', ', @Parent, ', \'', Content, '\ ,', UserId,', ', Title,', ', Nick, ')');
end if;

此字符标记'插入错误,我不知道在哪里:

我的错误:

CALL AddDynamicTable3('asd65xb', 'xxx', 5, NULL, 'MojWstep', 22, 'New title', 'Ethan')  Error Code: 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 '22,New title,Przemo)' at line 1

XXX - table_name

其他变量不是重要的例子tabSave,table_name ...

之前我写了相同的程序,但没有三个变量UserId,Title,Nick及其OK但是当我把这个变量放入时我只看到ERROR。

1 个答案:

答案 0 :(得分:0)

看看是否有效:

'\ ,', UserId,',
从第二个查询

,改为

'\ ', UserId,',