Since MySQL does not have sub-selects yet, you need to do this in
several steps. Here's one way to do it (might not be the best
way for you, though). If this doesn't work for you, please let
us know what the table structure is for the two tables.
You can create a temporary table that has the same structure as
your log table, then do:
INSERT INTO
temporary_log
SELECT
# This depends on what fields you have in the log table, example:
# id other_column url some_column
log.id, log.other_column, ip.newip, log.some_column
FROM
log, ip
WHERE
log.flag = ip.flag
Now, you must remove the old entries from the log table and insert
the new ones. You can use the REPLACE INTO syntax to do this, as
long as you have a unique key in the log table:
REPLACE INTO
log
SELECT
*
FROM
temporary_log
Tim
On Wed, Apr 21, 1999 at 04:15:35PM +0900, Yao Feng wrote:
> I think the manual of mysql is few to satisfy a newbie in sql.I have
> one question in this:
> One DATABASE data;
> include two TABLE log and ip;
> What I want to do is:
> update (or substitute) the TABLE log 's COLUMN url with TABLE ip 's
> COLUMN newip IF some condition happens(such as both TABLE 's COLUMN flag
> are same).
>
> Any advices to do it? It confused me for a few days.