The Little Guy Posted January 24, 2008 Share Posted January 24, 2008 instead of looping and using a mysql INSERT, UPDATE or DELETE, is it possible to insert using one command? so... say I want to delete,insert, or update rows where the unique id numbers are 1,23,54,77,200 how would I do that in one sql query? Quote Link to comment https://forums.phpfreaks.com/topic/87593-using-one-sql-query/ Share on other sites More sharing options...
phpSensei Posted January 24, 2008 Share Posted January 24, 2008 I don't think you can do this in one COMMAND, if you mean like ONE QUERY doing it all for you. Quote Link to comment https://forums.phpfreaks.com/topic/87593-using-one-sql-query/#findComment-447993 Share on other sites More sharing options...
The Little Guy Posted January 24, 2008 Author Share Posted January 24, 2008 what if they are all in an array? I know someone on here posted that you can do it... I don't know who, or what thread it was. Quote Link to comment https://forums.phpfreaks.com/topic/87593-using-one-sql-query/#findComment-448014 Share on other sites More sharing options...
killsite Posted January 24, 2008 Share Posted January 24, 2008 I'm not sure of exactly what type of database you have but based on the calls I've received as a webhost tech rep, MsSQL - yes you can write multiple lines and run it in a single db call. If using MySQL 5 db engine, you can by using PHP's exec() function in the PHP5 object model. With that, you should be able to pass one string for your queries. The only thing is you'll need command line root access in MySQL5. Be careful with coding this because the script will be prone to SQL injection hacks.. Yea, really really bad. Not 100% if this helps you. Hopefully someone else can elaborate or point you in the right direction here. Quote Link to comment https://forums.phpfreaks.com/topic/87593-using-one-sql-query/#findComment-448079 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.