Well, you need a primary key or unique index inorder to have any effect using the REPLACE syntax. Use the unique value (or set of values) from your replace command. i.e. If you have
Code:
REPLACE INTO table1 SET uk1=firstval, uk2=secondval, data1=notnecessarilyuniquestuff;
where uk* specifies a field in a unique index.
Rather than looking for the row's primary key id and using WHERE pk=@pkid, use WHERE uk1=firstval AND uk2=secondval.