Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/66.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/sql-server-2005/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_Sql - Fatal编程技术网

在MySQL中使用单个值更新列时插入?

在MySQL中使用单个值更新列时插入?,mysql,sql,Mysql,Sql,我对MySQL有一个非常简单的需求。我熟悉如何将数据从一个表插入到另一个表: INSERT INTO newTable (col1, col2) SELECT col1, col2 FROM otherTable 我想做的是稍微不同的事情,我有一个新的列,我想为所有插入的数据填充一个值 INSERT INTO newTable (col1, col2, col3=1984) SELECT col1, col2 FROM otherTable 我试过上述方法,也试过: INSERT INT

我对MySQL有一个非常简单的需求。我熟悉如何将数据从一个表插入到另一个表:

INSERT INTO newTable (col1, col2) 
SELECT col1, col2 FROM otherTable
我想做的是稍微不同的事情,我有一个新的列,我想为所有插入的数据填充一个值

INSERT INTO newTable (col1, col2, col3=1984) 
SELECT col1, col2 FROM otherTable
我试过上述方法,也试过:

INSERT INTO newTable (col1, col2, col3='1984') 
SELECT col1, col2 FROM otherTable
四处搜索,我没能很快在这里找到任何东西

你很接近

把它放在选择列表中

INSERT INTO newTable (col1, col2, col3) 
SELECT col1, col2,'1984' 
FROM otherTable
你很接近

把它放在选择列表中

INSERT INTO newTable (col1, col2, col3) 
SELECT col1, col2,'1984' 
FROM otherTable
你很接近

把它放在选择列表中

INSERT INTO newTable (col1, col2, col3) 
SELECT col1, col2,'1984' 
FROM otherTable
你很接近

把它放在选择列表中

INSERT INTO newTable (col1, col2, col3) 
SELECT col1, col2,'1984' 
FROM otherTable
插入新表(col1,col2,col3)从其他表中选择col1,col2,'1984'插入新表(col1,col2,col3)从其他表中选择col1,col2,'1984'插入新表(col1,col2,col3)从其他表中选择col1,col2,'1984'插入新表(col1,col2,col3)从其他表中选择col1,col2,'1984'