unrelativity unrelativity - 1 year ago 93
MySQL Question

Create if an entry doesn't exist, otherwise update?

Kinda strange to put it into words that short, heh.

Anyway, what I want is basically to update an entry in a table if it does exist, otherwise to create a new one filling it with the same data.

I know that's easy, but I'm relatively new to MySQL in terms of how much I've used it :P

Answer Source


 REPLACE INTO table SET id = 42, foo = 'bar';

See more in the MySQL documentation

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download