Update with one row which doesn't exist
I have a table as below and I want to update the values in the table, but also insert one or 2 rows.
So update rows 1 - 7 with changed values and add one row for a new value.
Table
ID (Auto increment) - ID_advertentie - VALUE
1 12 tst1
2 12 tst2
3 12 tst3
4 开发者_如何学Go 12 tst4
5 12 tst5
6 12 tst6
7 12 tst7
You may be interested in INSERT ... ON DUPLICATE KEY UPDATE syntax. So you'd have your insert query, and then have it update existing rows with that syntax.
Alternatively, if that doesn't work for you, just do two separate queries.
精彩评论