Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > transfer data between tables w/ mySQL

transfer data between tables w/ mySQL
Thread Tools
Junior Member
Join Date: Jul 2002
Location: Hang Loose, Hawaii
Status: Offline
Reply With Quote
Jul 11, 2002, 06:09 AM
 
i have two tables with four fields each.
i need to transfer (insert) the contents of fields 3 + 4 in table1 into fields 3 + 4 in table2 where field2 of table1 matches a certain value.


there is a way to transfer with PHP using a loop, but i'm just curious to know if mySQL can do it by itself.

this would transfer several rows with one query.
fields 3 + 4 have the same names in both tables.

any help in solving this "mistery" is appreciated.
Can I have that cookie?
     
ilukas  (op)
Junior Member
Join Date: Jul 2002
Location: Hang Loose, Hawaii
Status: Offline
Reply With Quote
Jul 23, 2002, 01:46 AM
 
wow! 12 days. nobody knows!
Can I have that cookie?
     
Mac Elite
Join Date: Aug 2000
Location: Minneapolis, MN
Status: Offline
Reply With Quote
Jul 23, 2002, 11:36 AM
 
Its likely a lack of experience and expertise in that 'field' (pun intended).

Check out the support at <a href="http://www.mysql.com" target="_blank">www.mysql.com</a>

You may be able to find some assistance from the source. Or look at other 'technical forums' rather than a 'mac-centric' site.

I can't speak for this forum, because I just found it from a search on google, but they may also have help on this forum for mysql.

<a href="http://www.tek-tips.com/gthreadminder.cfm/lev2/4/lev3/27/pid/436/" target="_blank">http://www.tek-tips.com/gthreadminder.cfm/lev2/4/lev3/27/pid/436/</a>

Good luck!
     
Mac Elite
Join Date: Jun 2001
Location: Dundee, Scotland
Status: Offline
Reply With Quote
Jul 23, 2002, 11:59 AM
 
</font><blockquote><font size="1" face="Geneva, Verdana, Arial, sans-serif">quote:</font><hr /><font size="1" face="Geneva, Verdana, Arial, sans-serif">Originally posted by ilukas:
<strong>i have two tables with four fields each.
i need to transfer (insert) the contents of fields 3 + 4 in table1 into fields 3 + 4 in table2 where field2 of table1 matches a certain value.


there is a way to transfer with PHP using a loop, but i'm just curious to know if mySQL can do it by itself.

this would transfer several rows with one query.
fields 3 + 4 have the same names in both tables.

any help in solving this "mistery" is appreciated.</strong></font><hr /></blockquote><font size="1" face="Geneva, Verdana, Arial, sans-serif">Do you need to do this once or every time a new peice of data is added or both?

You shouldn't ever store the same piece of data in two different places in the same database. What you would do instead is join the two tables together when it is needed.

however, if you are just trying to tidy your data up (so you can delete a table) then you can use a complex UPDATE.
     
ilukas  (op)
Junior Member
Join Date: Jul 2002
Location: Hang Loose, Hawaii
Status: Offline
Reply With Quote
Jul 26, 2002, 06:07 AM
 
</font><blockquote><font size="1" face="Geneva, Verdana, Arial, sans-serif">quote:</font><hr /><font size="1" face="Geneva, Verdana, Arial, sans-serif"><strong>Originally posted by sambeau:
Do you need to do this once or every time a new peice of data is added or both?

You shouldn't ever store the same piece of data in two different places in the same database. What you would do instead is join the two tables together when it is needed.

however, if you are just trying to tidy your data up (so you can delete a table) then you can use a complex UPDATE.</strong></font><hr /></blockquote><font size="1" face="Geneva, Verdana, Arial, sans-serif">i am trying to copy the contents of two cells for each row that matches a criterion in table 1 to two cells by the same name in their own new rows in table 2, then delete the already copied rows from table 1.
Can I have that cookie?
     
ilukas  (op)
Junior Member
Join Date: Jul 2002
Location: Hang Loose, Hawaii
Status: Offline
Reply With Quote
Jul 26, 2002, 08:46 PM
 
got it:

INSERT INTO table2(id,row3,row4) SELECT 74,table1.row3,table1.row4 WHERE table1.row2='id';

thanx for the help
Can I have that cookie?
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 12:35 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2