I want many values to be simultaneously inserted in my table having only 2 columns and if those values already exists then it has to be updated.. Though duplication for 1 column is possible but not for the second column.. I can easily do it with the following query.. But the problem is here only one row can only be considered… There are no primary keys.. PLZ HELP
INSERT INTO `table` (value1, value2)
SELECT 'stuff for value1', 'stuff for value2' FROM `table`
WHERE NOT EXISTS (SELECT * FROM `table`
WHERE value1='stuff for value1' AND value2='stuff for value2')
LIMIT 1
Try this
Insert into table name………….
on duplicate key update set column1=……
Alternative way ::
Step1 : Create a temp_table with same structure of that of table1
Step 2:
Step3: