duplicating a row in a DB
Posted: Tue Mar 09, 2004 6:34 am
is there a way to duplicate a row in a DB?
thnaks in advance
peleg
thnaks in advance
peleg
A community of PHP developers offering assistance, advice, discussion, and friendship.
http://forums.devnetwork.net/
Code: Select all
test=> select * from holyday; idholyday | who | from_date | to_date | fd_hd
-----------+----------+------------+------------+-------
1 | william | 2004-12-30 | 2004-12-30 | pm
2 | william | 2004-12-31 | 2004-12-31 | am
3 | patricia | 2004-12-31 | 2004-12-31 | am
4 | caroline | 2004-12-31 | 2004-12-31 | fd
5 | john | 2004-12-31 | 2004-12-31 | fd
6 | patricia | 2004-12-31 | 2004-12-31 | am
7 | william | 2004-12-31 | 2004-12-31 | am
(7 rows)
test=> insert into holyday values((select max(idholyday)+1 from holyday), (select who from holyday where idholyday = 2), (select from_date from holyday where idholyday = 2), (select to_date from holyday where idholyday = 2), (select fd_hd from holyday where idholyday = 2));
INSERT 17224 1
teste=> select * from holyday; idholyday | who | from_date | to_date | fd_hd
-----------+----------+------------+------------+-------
1 | william | 2004-12-30 | 2004-12-30 | pm
2 | william | 2004-12-31 | 2004-12-31 | am
3 | patricia | 2004-12-31 | 2004-12-31 | am
4 | caroline | 2004-12-31 | 2004-12-31 | fd
5 | john | 2004-12-31 | 2004-12-31 | fd
6 | patricia | 2004-12-31 | 2004-12-31 | am
7 | william | 2004-12-31 | 2004-12-31 | am
8 | william | 2004-12-31 | 2004-12-31 | am
(8 rows)
test=>