Forum Moderators: coopster

Message Too Old, No Replies

duplicating rows

         

canabatz

9:31 pm on Dec 1, 2011 (gmt 0)

10+ Year Member



Hi ,im facing little problem in duplicating rows.

it's not easy task for me, what i need:

i got this rows right now

id----------position-------------A_Q_ID
1---------------1--------------------5-----
2---------------2--------------------5-----
3---------------3--------------------5-----
4---------------1--------------------6-----
5---------------2--------------------6-----
6---------------3--------------------6-----

what i need is to duplicat all the rows and have them inserted after the rows i allready have like that:

id------------position-------------A_Q_ID
7----------------1-------------------7-----
8----------------2-------------------7-----
9----------------3-------------------7-----
10---------------1-------------------8-----
11---------------2-------------------8-----
12---------------3-------------------8-----

i tryed few ways without success .
any idea how to do that please? i cannot get the logic on doing it

thanks

eelixduppy

2:00 am on Dec 4, 2011 (gmt 0)



To be honest, I'm still a little confused as to what you are asking for. Can you please elaborate here or perhaps provide some context to aid in my understanding?

Habtom

4:37 am on Dec 4, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



If id is on auto increment, and if I understand you correctly, this query can replicate all the data you have in the table while at the same time incrementing A_Q_ID

INSERT INTO table_name(position, A_Q_ID) SELECT position, A_Q_ID+1 FROM mezmur_structure