簡體   English   中英

在一個MySQL列中插入多行時出現問題-PHP

[英]Issue while inserting multiple rows in one MySQL column- PHP

查詢語法如下:

INSERT INTO sent (username,password) VALUES 
 ('user','user2','user3','user4','user5','user6'),
 ('pass','pass2','pass3','pass4','pass5','pass6')

資源: http : //dev.mysql.com/doc/refman/5.5/en/insert.html

mysql_error()總是向我顯示以下內容:

Column count doesn't match value count at row 1

我不知道該怎么辦。 現在是時候問你這個了。

您為2列指定了6個值。 列數和值必須匹配。 您想要的是:

INSERT INTO sent (username,password) VALUES ('user','pass'),('user2','pass2'),('user3','pass3'),('user4','pass4'),('user5','pass5'),('user6','pass6')

有關更多詳細信息,請參見MySQL文檔

使用VALUES語法的INSERT語句可以插入多行。 為此,請包括多個列值列表,每個列值括在括號內並用逗號分隔。 例:

INSERT INTO tbl_name (a,b,c) VALUES(1,2,3),(4,5,6),(7,8,9);

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM