Use INSERT ... ON DUPLICATE KEY UPDATE
QUERY:
INSERT INTO table (id, name, age) VALUES(1, "A", 19) ON DUPLICATE KEY UPDATE
name="A", age=19
More Related Contents:
- How do I update if exists, insert if not (AKA “upsert” or “merge”) in MySQL?
- How do I UPDATE a row in a table or INSERT it if it doesn’t exist?
- SQL Query needed for fetch value from Two identical table but not fully identical table
- Error related to only_full_group_by when executing a query in MySql
- Remove duplicate rows in MySQL
- How to do the Recursive SELECT query in MySQL?
- MySQL, update multiple tables with one query
- Error Code: 2013. Lost connection to MySQL server during query
- SQLite INSERT – ON DUPLICATE KEY UPDATE (UPSERT)
- SQL Performance UNION vs OR
- How do I select an entire row which has the largest ID in the table?
- How do I use on delete cascade in mysql?
- Adding a leading zero to some values in column in MySQL
- Using SQL to determine word count stats of a text field
- Update one MySQL table with values from another
- MySQL/MariaDB – order by inside subquery
- How to transpose mysql table rows into columns
- View’s SELECT contains a subquery in the FROM clause
- MySQL Group By and Sum total value of other column
- MySQL incorrect key file for tmp table when making multiple joins
- Does the order of conditions in a WHERE clause affect MySQL performance?
- Difference between these two joining table approaches?
- MySQL Stored Procedures not working with SELECT (basic question)
- MySQL query, MAX() + GROUP BY
- MySQL export into outfile : CSV escaping chars
- Simple Random Samples from a MySQL Sql database
- ALTER table – adding AUTOINCREMENT in MySQL
- MySQL Select minimum/maximum among two (or more) given values
- MySQL: Computed Column
- mySQL query to search all tables within a database for a string?