JuanPablo
JuanPablo

Reputation: 24774

replace a value in a insert

how replace a value when I use insert mysql command ?

Upvotes: 0

Views: 214

Answers (3)

Aaron
Aaron

Reputation: 10848

If you're meaning that you want to only update the current value in the database and not insert a new value, you should use the UPDATE command: http://dev.mysql.com/doc/refman/5.0/en/update.html

If you actually do want to insert something into the database, but want to replace the value before it gets inserted, you could use PHP's str_replace() or preg_replace() function depending on what you need to do. I'm not sure what language you're using, but if it's .NET, you could use the Replace() method.

str_replace() - http://php.net/manual/en/function.str-replace.php

preg_replace() - http://php.net/manual/en/function.preg-replace.php

Upvotes: 0

srgerg
srgerg

Reputation: 19329

You can use the "on duplicate key update" syntax to update an existing row in an insert statement.

Upvotes: 1

Rob P.
Rob P.

Reputation: 15071

INSERT - creates a new value. UPDATE - Replaces/modifies an existing value.

Upvotes: 0

Related Questions