RE: [PHP] Inserting Records from a table into another table..
| From: | Jay Blanchard | Date: | Thu, 22 May 2003 12:22:46 +0000 |
| Subject: | RE: [PHP] Inserting Records from a table into another table.. | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-148540@lists.php.net to get a copy of this message | ||
[snip]
How can I take records from one table into another based on a criteria..
[/snip]
Do a SELECT with your first query for the proper criteria. WHILE you
have that data INSERT or UPDATE the other table accordingly.
{assuming MySQL for example}
$sql = "SELECT a.foo, a.bar FROM table_a a, table_b b WHERE a.foo =
b.foo ";
$result = mysql_query($sql, $database_connection);
while($rows = mysql_fetch_object($result)){
$update = "UPDATE table_b SET bar_column = '" . $rows->bar . "'
";
$do_query = mysql_query($update, $database_connection);
}
HTH!
Jay