This doesn't work:
INSERT INTO users (username, password) VALUES ("Jack","123") WHERE id='1';
Any ideas how to narrow insertion to a particular row by id?
This doesn't work:
INSERT INTO users (username, password) VALUES ("Jack","123") WHERE id='1';
Any ideas how to narrow insertion to a particular row by id?
This will work only if the
id
field is unique/pk (not composite PK though) Also, this will insert if noid
of value 1 is found and update otherwise the record withid
1 if it does exists.Try this:
Or if you're actually trying to insert:
A conditional insert for use typically in a MySQL script would be:
You need to use dummy table dual.
In this example, only the second insert-statement will actually insert data into the table:
In an insert statement you wouldn't have an existing row to do a where claues on? You are inserting a new row, did you mean to do an update statment?
I think you are looking for UPDATE and not insert?
To add a WHERE clause inside an INSERT statement simply;