unrelativity unrelativity - 5 months ago 38
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



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

See more in the MySQL documentation