allspiritseve Posted December 12, 2007 Share Posted December 12, 2007 I would like to use a REPLACE query using two separate text fields as keys. If both keys match, the record is replaced, while if one or the other matches, but not both, a new record is inserted. I am not sure exactly what my db structure needs to look like, as I've only ever used an int pkey with auto-increment. I am using MySQL 5.0.45 on a LAMP server. Thanks, Cory Link to comment https://forums.phpfreaks.com/topic/81388-solved-replace-using-two-keys/ Share on other sites More sharing options...
fenway Posted December 12, 2007 Share Posted December 12, 2007 Is your UNIQUE index multi-column? Link to comment https://forums.phpfreaks.com/topic/81388-solved-replace-using-two-keys/#findComment-413141 Share on other sites More sharing options...
allspiritseve Posted December 12, 2007 Author Share Posted December 12, 2007 Yes, though I wasn't sure exactly if that was what I needed. Even with the multi-column index, a REPLACE query still inserts when both columns are specified. Is there something else I need to do? Link to comment https://forums.phpfreaks.com/topic/81388-solved-replace-using-two-keys/#findComment-413178 Share on other sites More sharing options...
fenway Posted December 13, 2007 Share Posted December 13, 2007 Hmmm... that's unusual.. could you post your table structure so I can test it? Link to comment https://forums.phpfreaks.com/topic/81388-solved-replace-using-two-keys/#findComment-413477 Share on other sites More sharing options...
allspiritseve Posted December 13, 2007 Author Share Posted December 13, 2007 You know, I figured it out. I had a multi column INDEX instead of UNIQUE. Link to comment https://forums.phpfreaks.com/topic/81388-solved-replace-using-two-keys/#findComment-413603 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.