Swapnanil Saha
Swapnanil Saha

Reputation: 134

MySQL multiple insert: How to write a query to insert the new rows and ignore inserting duplicate rows?

I want to insert multiple rows in a MySQL table at once. One of the columns, column c, of that table is unique indexed. How to write a query to insert the new rows(rows where value of column c is not equal to the column c value of any previously inserted row) only and ignore inserting duplicate rows?

Upvotes: 0

Views: 91

Answers (1)

praveen_programmer
praveen_programmer

Reputation: 1062

You can use INSERT IGNORE instead of insert.Query will be like this .

 INSERT IGNORE INTO person_tbl (last_name, first_name)
 VALUES( 'Jay', 'Thomas');

Upvotes: 2

Related Questions