Hello, I searching for way to perform bath MySQL queries in PHP. I already know about loops, this however still same multiple queries, but with more load, because now its also loop. What i trying to find is pure way to make bath queries, then mysql_query being executed one time. I found what if you instead of ; use ;; like this: mysql_query("DELETE FROM table1 WHERE value='1';; DELETE FROM table2 WHERE value='2';;"); PHP: MySQL will not return error, however query will not be executed. I don't need to view result, i just need to execute query. Any ideas?
I think you mean BATCH queries, right? Can you give us an example of how you are trying to use the batch queries? It will put the DELETE sample into context. If you simply want to delete multiple rows from the table, you can use the following format: DELETE FROM table WHERE value IN ('1','2','3','4','5') or use a subquery for larger value sets.
i need to execute DELETE queries for 1-10 tables(depending on user selection): DELETE FROM table1 WHERE value1='x'; DELETE FROM table2 WHERE value4='x'; DELETE FROM table3 WHERE value8='x'; and so on...
You need to tell more of what you need. Is this enough? $tables = array('table1','table2','tablewhateveryoulike'); foreach($tables as $t) { mysql_query("DELETE FROM ".$table." WHERE value='1'"); } PHP:
Create an empty table and setup a delete trigger on this table In the delete trigger create multiple delete statements for all your tables. Then perform your delete on the empty table, this will trigger a delete on all your other tables.