Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/image-processing/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Mysql在只有一个字段变化的地方插入多个_Mysql - Fatal编程技术网

Mysql在只有一个字段变化的地方插入多个

Mysql在只有一个字段变化的地方插入多个,mysql,Mysql,如果我必须在一个表中插入几百行,但是我插入的数据只针对一列,那么在没有几百个单独插入的情况下,最好的方法是什么 即 几百排?没什么。只需将其展开并生成一个具有多个值的INSERT语句: INSERT INTO the_table (name, lastname, lastlogin) VALUES ('bill','smith', '2015-08-01'), ('bill','smith', '2015-08-02'), ... 几百排?没什么。只需将其展开并生成一个

如果我必须在一个表中插入几百行,但是我插入的数据只针对一列,那么在没有几百个单独插入的情况下,最好的方法是什么


几百排?没什么。只需将其展开并生成一个具有多个值的
INSERT
语句:

INSERT INTO the_table (name, lastname, lastlogin)
  VALUES ('bill','smith', '2015-08-01'),
     ('bill','smith', '2015-08-02'),
     ...

几百排?没什么。只需将其展开并生成一个具有多个值的
INSERT
语句:

INSERT INTO the_table (name, lastname, lastlogin)
  VALUES ('bill','smith', '2015-08-01'),
     ('bill','smith', '2015-08-02'),
     ...

您可以使用变量和函数来编写大约100次查询:

SET @variable_field=NOW(); INSERT INTO login VALUES("bill", "smith", @variable_field); 设置@variable_field=NOW(); 在登录值中插入(“比尔”、“史密斯”、“变量”字段);
您可以使用变量和函数来编写大约100次查询:

SET @variable_field=NOW(); INSERT INTO login VALUES("bill", "smith", @variable_field); 设置@variable_field=NOW(); 在登录值中插入(“比尔”、“史密斯”、“变量”字段);