Welcome to the GoFuckYourself.com - Adult Webmaster Forum forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Post New Thread Reply

Register GFY Rules Calendar
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >
Discuss what's fucking going on, and which programs are best and worst. One-time "program" announcements from "established" webmasters are allowed.

 
Thread Tools
Old 05-21-2009, 08:03 PM   #1
Pics Traffic
Confirmed User
 
Pics Traffic's Avatar
 
Industry Role:
Join Date: Jun 2004
Location: Europe
Posts: 3,055
Need MySQL help with short query..

I have two tables A and B. I want update table A with all entries from table B. Tables have different structures but 2 colums that I want to copy are the same. Help brother out.
Pics Traffic is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 05-21-2009, 09:05 PM   #2
rowan
Too lazy to set a custom title
 
Join Date: Mar 2002
Location: Australia
Posts: 17,393
If you're ever scratching your head about a command, do a search for "COMMAND mysql" and the mysql site is usually the first result.

I presume you want something like this...

INSERT INTO table_B (column1,column2) SELECT column1,column2 FROM table_A;

Back up your data first.
rowan is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 05-21-2009, 09:50 PM   #3
Pics Traffic
Confirmed User
 
Pics Traffic's Avatar
 
Industry Role:
Join Date: Jun 2004
Location: Europe
Posts: 3,055
Quote:
Originally Posted by rowan View Post
If you're ever scratching your head about a command, do a search for "COMMAND mysql" and the mysql site is usually the first result.

I presume you want something like this...

INSERT INTO table_B (column1,column2) SELECT column1,column2 FROM table_A;

Back up your data first.
sorry, I should have added that I need to do UPDATE not insert because there's a default value in that field already. I looked all over but still can't figure out what Im doing wrong.
Pics Traffic is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 05-21-2009, 10:05 PM   #4
Pics Traffic
Confirmed User
 
Pics Traffic's Avatar
 
Industry Role:
Join Date: Jun 2004
Location: Europe
Posts: 3,055
Ok, case closed. Figured it out.
Pics Traffic is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 05-21-2009, 10:24 PM   #5
rowan
Too lazy to set a custom title
 
Join Date: Mar 2002
Location: Australia
Posts: 17,393
So what was the answer? REPLACE INTO?
rowan is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 05-21-2009, 10:43 PM   #6
Iron Fist
Too lazy to set a custom title
 
Join Date: Dec 2006
Posts: 23,400
Love these threads...

HELP ME HELP ME...

Okay FUCK OFF... I GOT IT...

Yeech... at least post what you did that fixed it.
__________________
i like waffles
Iron Fist is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 05-21-2009, 11:01 PM   #7
Pics Traffic
Confirmed User
 
Pics Traffic's Avatar
 
Industry Role:
Join Date: Jun 2004
Location: Europe
Posts: 3,055
Quote:
Originally Posted by rowan View Post
So what was the answer? REPLACE INTO?
no, just update.. I was overdoing it. It was easy one.

UPDATE videos v, banners b SET v.BANNER_NAME = b.BANNER_NAME, v.BANNER_URL = b.BANNER_URL WHERE v.VIDEOID = b.VIDEOID
Pics Traffic is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Post New Thread Reply
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >

Bookmarks



Advertising inquiries - marketing at gfy dot com

Contact Admin - Advertise - GFY Rules - Top

©2000-, AI Media Network Inc



Powered by vBulletin
Copyright © 2000- Jelsoft Enterprises Limited.