Need an update in how to update

admin

Administrator
Staff member
Hi,

I need to update a table based on another table's values.
The two tables are table1 and table2.

Table1
------------
ID | VALUE
------------
1 | 1
2 | 0
3 | 0
4 | 1

Table2
------------
ID | VALUE
------------
1 | 0
2 | 0
3 | 0
4 | 0

I want to update Table2 and set all VALUEs to "1" where the ID corresponds with the IDs in Table1 that has VALUE set to "1".
The result of the update should be that VALUE for ID 1 and 4 is "1"

This is a bad query, but that somewhat explains what I want to accomplish:
Update table2 set value = <!-- m --><a class="postlink" href="http://www.phpbuilder.com/board/archive/index.php/1">http://www.phpbuilder.com/board/archive/index.php/1</a><!-- m --> where table2.ID = table1.ID and table1.VALUE = 1
 
Back
Top