From: Christian Mack Date: April 21 1999 5:28pm Subject: Re: [Question] About 2 table in one database List-Archive: http://lists.mysql.com/mysql/2191 Message-Id: <371E0AC5.4985018@compal.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit 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. Hi Yao If you have a UNIQUE or PRIMARY KEY on log, you can do this: 1) CREATE a temporary table with all columns like log. 2) INSERT INTO temp_log (column1, column2, ...., url) SELECT log.colum1, log.column2, ..., ip.newip FROM log, ip WHERE log.flag=ip.flag 3) REPLACE INTO log SELECT temp_log 4) DROP temp_log You can hold temp_log for the next round and just delete the contents, if needed. Tschau Christian