SetToLoki Posted October 21, 2007 Share Posted October 21, 2007 I have some data in a php array and I want to insert the data from this array into several tables. now my problem is that some of the data will allready be entered into the databse and if it is I want to update it. if it isn't there I need to add it. is there an sql query that would help me do this efficently Quote Link to comment https://forums.phpfreaks.com/topic/74211-solved-update-or-insert/ Share on other sites More sharing options...
trq Posted October 21, 2007 Share Posted October 21, 2007 is there an sql query that would help me do this efficently Yeah, take a look at the REPLACE INTO syntax. Quote Link to comment https://forums.phpfreaks.com/topic/74211-solved-update-or-insert/#findComment-374869 Share on other sites More sharing options...
Simon Moon Posted October 21, 2007 Share Posted October 21, 2007 Also a possible more accurate thing of what you describe you want is this bit. http://dev.mysql.com/doc/refman/5.0/en/insert-on-duplicate.html Maybe there is a better way to do what you want al together if you give more details on what you are working on. Quote Link to comment https://forums.phpfreaks.com/topic/74211-solved-update-or-insert/#findComment-374951 Share on other sites More sharing options...
fenway Posted October 22, 2007 Share Posted October 22, 2007 Also a possible more accurate thing of what you describe you want is this bit. http://dev.mysql.com/doc/refman/5.0/en/insert-on-duplicate.html Maybe there is a better way to do what you want al together if you give more details on what you are working on. If appropriate, this is better, since REPLACE does an implicit DELETE. Quote Link to comment https://forums.phpfreaks.com/topic/74211-solved-update-or-insert/#findComment-375449 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.