Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/78.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
SQL使用更新表中的更新更新主表_Sql_Sql Server - Fatal编程技术网

SQL使用更新表中的更新更新主表

SQL使用更新表中的更新更新主表,sql,sql-server,Sql,Sql Server,我正在尝试从我的更新表更新我的主表,下面的查询有什么问题 UPDATE master_table SET master_table.description = master_table_import.description FROM master_table_import WHERE master_table.user_id = master_table_import.user_id 您缺少表之间的联接。试着这样做: UPDATE m

我正在尝试从我的更新表更新我的主表,下面的查询有什么问题

UPDATE       master_table
SET          master_table.description = master_table_import.description
FROM         master_table_import
WHERE        master_table.user_id = master_table_import.user_id

您缺少表之间的联接。试着这样做:

UPDATE mt SET mt.Description = mti.Description
FROM master_table mt
INNER JOIN master_table_import mti
ON mt.user_id = mti.user_id;

为表使用别名总是一个好主意。要更新,您必须将目标表与源表联接:

UPDATE       mt
SET          description = mti.description
FROM         master_table mt INNER JOIN master_table_import mti
WHERE        mt.user_id = mti.user_id