SQL INSERT INTO SELECT 语句

2022-07-26  本文已影响0人  赵哥窟

SQL INSERT INTO SELECT 语句
INSERT INTO SELECT 语句从一个表复制数据,然后把数据插入到一个已存在的表中。目标表中任何已存在的行都不会受影响。

INSERT INTO Websites (name, country)
SELECT app_name, country FROM apps;
INSERT INTO Websites (name, country)
SELECT app_name, country FROM apps
WHERE id=1;
INSERT INTO TABLE1 (PK_ID, PRODUCT_ID, IMAGE_CODE, IMAGE_SCENE, REQUIRED, RAW_CREATE_USER, RAW_CREATE_TIME, RAW_UPDATE_USER, RAW_UPDATE_TIME)
SELECT MD5(UUID()) t2.PRODUCT_ID, 'ID_CARD_BACK', '1', '1', 'SYS', NOW(), 'SYS', now() FROM TABLE2 t2;
上一篇下一篇

猜你喜欢

热点阅读