我的ingres db中有一个表,其中包含以下值,例如
grd gsd Name Location
112 04 Joe Test
我想创建一个新行,复制相同的数据但是" grd"值更改为新值,如下所示
grd gsd Name Location
113 04 Joe Test
如何在优化的sql语句中实现此目的?
答案 0 :(得分:2)
尝试这样的事情:
INSERT INTO your_table (grd, gsd, Name, Location)
SELECT
grd,--or change it here as you need (for example replacing with value 113)
gsd,
Name,
Location
FROM your_table
--WHERE some condition (e.g. grd = 112)
答案 1 :(得分:-1)
insert into MyTable(field1, field2, "113")
select field1, field2, grd from MyTable where grd = "112";