當我使用下面的命令:如何在錶行插入MySQL命令
insert into history (id, command)
values(2,'insert into show(id, moderator_ID, film_ID, time_length, adress, details) values(42,2,1,'123','123','123')');
它返回一個錯誤:缺少逗號。爲什麼?
當我使用下面的命令:如何在錶行插入MySQL命令
insert into history (id, command)
values(2,'insert into show(id, moderator_ID, film_ID, time_length, adress, details) values(42,2,1,'123','123','123')');
它返回一個錯誤:缺少逗號。爲什麼?
使用雙引號的,而不是單引號在第二插入查詢
insert into history (id, command)
values (2,'insert into show
(id, moderator_ID, film_ID, time_length, adress, details)
values (42,2,1,\"123\",\"123\",\"123\")');
使用雙引號是這樣的:
INSERT INTO `history` (`id` , `command`)
VALUES ('2', 'insert into show(id, moderator_ID, film_ID, time_length, adress, details) values(42,2,1,''123'',''123'',''123'')');
不工作。返回:標識符不能以字母和數字以外的任何ASCII字符開頭... – Kumara
您的字段是什麼類型?嘗試更改爲VARCHAR latin1_swedish –
我試過了,並運行http://prntscr.com/3i5uek –
它的工作原理,但我在java中執行它,並在一個變量中使用命令值。我嘗試了「雙引號」整個命令,但「雙引號」的最大大小是30個字符。有任何想法嗎? – Kumara
只需在雙引號前使用'\'。 – unknown
檢查我更新的查詢。 – unknown