NYCPHP Meetup

NYPHP.org

[nycphp-talk] mySQL: update table from another table

Brian Pang bpang at bpang.com
Thu Oct 30 11:36:13 EST 2003


was it ever "mandated" that subject lines, if "OT" are somehow labeled?
"mySQL:" is my attempt to alert the reader that this isn't directly PHP
related.


I need to update table2 with data from table1

the mysql4 code would be:
update table2,table1 set table2.field = table1.field where table2.id =
table1.id

how is this done in mysql 3.x ?

current mysql docs only show solutions for 4.x

---
Of course, I could do a php solution, but that seems less elegant.
conceptually:
select id,field from table2
foreach(id)
select field from table1 where table1.id = id
update table2 set table2.field = field where table2.id = id


thanks
Brian




More information about the talk mailing list