I have the following table (tbl_test) in MySQL server:
id AUTO_INCRECMENT PRIMARY
text1 VARCHAR(20)
and inserted a row of data:
INSERT INTO tbl_test (text1) VALUES ('Apple')
id text1
===========
1 Apple
Then, I plan to use REPLACE INTO to check for existing value and insert if needed:
REPLACE INTO tbl_test (text1) VALUES ('Apple')
But it inserted a new row.
id text1
===========
1 Apple
2 Apple
How can I check for existing data and insert only if needed (ignoring auto increment primary key)?