On Fri, 2001-11-02 at 09:57, Paul DuBois wrote: > At 9:47 AM -0700 11/2/01, Steve Meyers wrote: > >That's a dangerous solution. If there are more columns in test2 than ID > >and Value, the REPLACE will delete those values. As you noted in the > >manual, the old record is deleted before the new record is inserted. > > > >Multi-table updates should happen in 4.1, I think, which is due out > >fairly soon. > > > >If you want to do it Rick's way, try the following: > > > >REPLACE INTO test2 (test2.id, test2.value, test2.other) > >SELECT test1.id, test1.value, test2.other FROM test1, test2 WHERE > >test1.id=1 and test2.id=test1.id > > What if there's no existing record to replace? > Won't the SELECT select no rows, with the result that the statement > does nothing? >
That's true. However, he's trying to emulate a multi-table update, so that would actually be the desired result. I think so, anyway. I avoid using REPLACE instead of UPDATE like the plague, as it can wreak havoc if you ever change your table structure... Steve Meyers --------------------------------------------------------------------- Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php