SQL Prevent Duplicate INSERT – MySql
SQL Prevent Duplicate INSERT – MySql : If you are working with mysql insert operation and want to stop duplicate insertion operation . You can use INSERT IGNORE statement. This will prevent the duplicate row insertion.
SQL Prevent Duplicate INSERT – MySql
Here is an example of Insert ignore statement in mysql
SQL Prevent Duplicate INSERT – MySql
mysql> INSERT IGNORE INTO users (user_id, email) VALUES (32, test@ymail.com); Query OK, 1 row affected (0.01 sec) mysql> INSERT IGNORE INTO users (user_id, email) VALUES (32, test@ymail.com); Query OK, 0 rows affected (0.00 sec) |
The above example clearly shows when you run the same query to insert the same data it will not insert the data again.
Advertisements
Add Comment
📖 Read More
- 1. Get list of MySQL user accounts
- 2. Can't connect to local MySQL server through socket '/var/mysql/mysql.sock'
- 3. MySQL Grant all privileges on database