CREATE TABLE dualx(
x_id VARCHAR(5) NOT NULL ,
x_con VARCHAR(10)
) CREATE TABLE dualy(
y_id VARCHAR(5) NOT NULL ,
y_con VARCHAR(10)
) INSERT INTO dualx VALUES ('','xxx');
INSERT INTO dualx VALUES ('','xxx');
INSERT INTO dualx VALUES ('','xxx'); INSERT INTO dualy VALUES ('','');
INSERT INTO dualy VALUES ('','');
INSERT INTO dualy VALUES ('',''); UPDATE dualx SET (x_con) = (SELECT y.y_con FROM dualy y WHERE dualx.x_id = y.y_id) SELECT * FROM dualx;
SELECT * FROM dualy;
DROP TABLE dualx;
DROP TABLE dualy;

UPDATE dualx SET (x_con) = (SELECT y.y_con FROM dualy y WHERE dualx.x_id = y.y_id) 其中SELECT y.y_con FROM dualy y WHERE dualx.x_id = y.y_id不能返回多行,否则报错。

05-13 14:23