I\'m writing an application and I\'m using MySQL as DBMS, we are downloading property offers and there were some performance issues. The old architecture looked like this: A
I can see that you have solved your problem, but to answer your original question:
REPLACE INTO
does not have a WHERE
clause.
The REPLACE INTO
syntax works exactly like INSERT INTO
except that any old rows with the same primary or unique key is automaticly deleted before the new row is inserted.
This means that instead of a WHERE
clause, you should add the primary key to the values beeing replaced to limit your update.
REPLACE INTO myTable (
myPrimaryKey,
myColumn1,
myColumn2
) VALUES (
100,
'value1',
'value2'
);
...will provide the same result as...
UPDATE myTable
SET myColumn1 = 'value1', myColumn2 = 'value2'
WHERE myPrimaryKey = 100;
...or more exactly:
DELETE FROM myTable WHERE myPrimaryKey = 100;
INSERT INTO myTable(
myPrimaryKey,
myColumn1,
myColumn2
) VALUES (
100,
'value1',
'value2'
);
In your documentation link, they show three alternate forms of the replace
command. Even though elided, the only one that can accept a where clause is the third form with the trailing select
.
replace
seems like overkill relative to update
if I am understanding your task properly.