[Table1 Columns: Server, Site, App_Name]
[Table2 Columns: Event, Server, Site, App_Name]
INSERT INTO Table2 Values(Server, Site, App_Name)
SELECT * FROM Table2 WHERE Site IN ('ABC');
UPDATE Table2 SET Event = 'XYZ' WHERE Site IS NOT NULL;
我想为query1中创建的所有行设置相同的Event值。如果我更新,它会破坏以前的一些数据。如何将第二个查询作为INSERT的一部分?
答案 0 :(得分:0)
试试这个..
INSERT INTO Table2 Values(Server, Site, App_Name)
SELECT Server,'XYZ',App_Name FROM Table2 WHERE Site IN ('ABC');