Jump to content

Copying Rows

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
6 replies to this topic

#1
Void

Void

    Programming Expert

  • Members
  • PipPipPipPipPipPip
  • 411 posts
Is there a way to copy rows in MySQL? I need to copy the same data 15 times and would rather not type it in. The only thing I need changed is the ID which is set to auto-increment.
Void

#2
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
I would use the Insert command from SQL 15 times, specifying everything except the ID.
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#3
Guest_Jordan_*

Guest_Jordan_*
  • Guests

WingedPanther said:

I would use the Insert command from SQL 15 times, specifying everything except the ID.

After looking through the commands I couldn't find anything so I would have to suggest what WingedPanther said as well.

#4
voldron

voldron

    Newbie

  • Members
  • Pip
  • 4 posts
Couldn't this be possibly done using a sub query?

INSERT INTO employees3 (id,Lastname,Firstname,Title) (SELECT id,Lastname,Firstname,Title FROM employees WHERE Title='manager');


Something like the above. I know that Subquerys have just recently be supported fully in MySQL
;-)

#5
Guest_Jordan_*

Guest_Jordan_*
  • Guests
It might be possible for this to work. It would be interesting to know if it did work.

#6
voldron

voldron

    Newbie

  • Members
  • Pip
  • 4 posts
yep it worked. I did a little test and it worked

#7
Patrick

Patrick

    Programmer

  • Members
  • PipPipPipPip
  • 101 posts
Yeah I also used this command and it's working very efficiently. That is really a great work. I would like to appreciate all the effort drawn by members of this forum.

Cheers.