0

在 MySQL 中插入>

这是程序代码的一部分:

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 - 表名

其他变量不显着 例如 tabSave, table_name ...

早些时候我编写了相同的程序,但没有三个变量 UserId、Title、Nick 和它的 OK,但是当我放置这些变量时,我只看到 ERROR。

4

1 回答 1

0

看看这是否有效:

'\ ,', UserId,',

从第二个查询,更改为

'\ ', UserId,',
于 2012-07-25T12:47:28.703 回答