* Thus wrote John Taylor-Johnston ([EMAIL PROTECTED]):
> Any ideas? I want to avoid having two "mysql_query($sql)". I'm basically looking for 
> better functionality and wanting to learn how to clean up my code.
> 

there are a couple options, the insert has a extra option, 'ON
DUPLICATE KEY':
  http://www.mysql.com/doc/en/INSERT.html

Or use the REPLACE syntax:
  http://www.mysql.com/doc/en/REPLACE.html

Be forewarned about the REPLACE, that there may be side effects
because it not only replaces on the primary key value but any
UNIQUE index.

For example (ingore syntax errors),

create table (
 id   Primary Key
 name UNIQUE
)

Data:
1, 'Name1'
2, 'Name2'

replace into table (id, name) values (2, 'Name1');

I havn't tested this situation, but to me that, seems like an
awkward position to be in.

Curt.


Curt
-- 
"My PHP key is worn out"

  PHP List stats since 1997: 
          http://zirzow.dyndns.org/html/mlists/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to