INSERT INTO table1
(c1, c2, c3)
(SELECT v1, v2, v3 FROM table2)
答案是可以的,具体的语法如下:
UPDATE table1 alias
SET (column_name,column_name ) = (
SELECT (column_name, column_name)
FROM table2
WHERE column_name = alias.column_name)
WHERE column_name = VALUE
下面是这样一个例子: 两个表a、b,想使b中的memo字段值等于a表中对应id的name值 表a:
id name
1 王
2 李
3 张
表b:
id ClientName
1
2
3
(MS SQL Server)语句:
UPDATE b SET ClientName = a.name FROM a,b WHERE a.id = b.id
(Oralce)语句:
UPDATE b SET (ClientName) = (SELECT name FROM a WHERE b.id = a.id)