Jump to content


Photo

transfer mysql data to another table?


  • Please log in to reply
4 replies to this topic

#1 tjhilder

tjhilder
  • Members
  • PipPipPip
  • Advanced Member
  • 136 posts
  • LocationKent, UK

Posted 05 January 2006 - 08:55 PM

Hi,

say you have a table called news and then a table called archives, and you want to transfer the data from news to archives, is this possible? I want to be able to transfer it by ticking the news you want transfered then clicking a button (i get all that fine) just wondering how i would go about transfering it, is it possible?

thanks in advance.

#2 LazyJones

LazyJones
  • Members
  • PipPipPip
  • Advanced Member
  • 78 posts

Posted 05 January 2006 - 09:00 PM

Sure is possible. Select from news -> Insert into archives -> (delete old news)


#3 fenway

fenway
  • Staff Alumni
  • MySQL Si-Fu / PHP Resident Alien
  • 16,199 posts
  • LocationToronto, ON

Posted 05 January 2006 - 09:05 PM

Alternatively, "INSERT INTO archives SELECT * FROM news", and then "DELETE * FROM news WHERE uid<(SELECT MAX(uid) FROM archives)".
Seriously... if people don't start reading this before posting, I'm going to consider not answering at all.

#4 LazyJones

LazyJones
  • Members
  • PipPipPip
  • Advanced Member
  • 78 posts

Posted 05 January 2006 - 09:15 PM

[!--quoteo(post=333662:date=Jan 5 2006, 04:05 PM:name=fenway)--][div class=\'quotetop\']QUOTE(fenway @ Jan 5 2006, 04:05 PM) View Post[/div][div class=\'quotemain\'][!--quotec--]
Alternatively, "INSERT INTO archives SELECT * FROM news", and then "DELETE * FROM archives WHERE uid=(SELECT MAX(uid) FROM archives)".
[/quote]

Why delete archived news :)

I thought the basic ideas was to insert old news into archives and delete them from the news table

#5 fenway

fenway
  • Staff Alumni
  • MySQL Si-Fu / PHP Resident Alien
  • 16,199 posts
  • LocationToronto, ON

Posted 05 January 2006 - 09:54 PM

Yeah, yeah, my bad, I fixed my previous post.
Seriously... if people don't start reading this before posting, I'm going to consider not answering at all.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users