Using REPLACE


The REPLACE statement is exactly like the INSERT statement except that if a key clash occurs, the new row you are inserting will replace the old row.

This is the general form of REPLACE from the MySQL manual:

 
 REPLACE [LOW_PRIORITY  DELAYED]         [INTO]  tbl_name  [(  col_name  ,...)]         VALUES (  expression  ,...),(...),... or  REPLACE [LOW_PRIORITY  DELAYED]         [INTO]  tbl_name  [(  col_name  ,...)]         SELECT ... or  REPLACE [LOW_PRIORITY  DELAYED]         [INTO]  tbl_name  SET  col_name  =  expression, col_name  =  expression  ,... 

The similarity to INSERT should be obvious.



MySQL Tutorial
MySQL Tutorial
ISBN: 0672325845
EAN: 2147483647
Year: 2003
Pages: 261

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net