Delete rows from multiple tables as one query

NoviceMe

I am running following delete statements i want to know if it is possible at all to combine them somehow:

DELETE from schools where visibility like 'revoked'

DELETE FROM bookmark_schools
WHERE school_id NOT IN (SELECT s.id FROM school s)

DELETE FROM school_addresses 
WHERE school_id NOT IN (SELECT s.id FROM school s)

DELETE FROM school_highlights 
WHERE school_id NOT IN (SELECT s.id FROM school s)

DELETE FROM school_images 
WHERE school_id NOT IN (SELECT s.id FROM school s)

...

And so on i have like 15 queries like this. Is it possible to run them together rather than running them individually?

Erix

You can combine them into a single statement as others have indicated, but note that this will still be a single threaded operation.

If your goal is to improve performance / parallelize this operation, you may want to write a script which creates the 15 different client threads to run the statements concurrently.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Select random rows from multiple tables in one query

From Dev

Postgresql delete multiple rows from multiple tables

From Dev

Delete rows from multiple tables in a database

From Dev

DELETE rows from multiple tables with JOIN in Mysql

From Dev

delete from 3 tables with one query

From Dev

Query to delete from multiple tables in Access

From Dev

Query to delete from multiple tables in Access

From Dev

Pulling Multiple Rows from Multiple Tables and Ordering Them Using One MySQL Query

From Dev

Delete from multiple related tables on one id?

From Dev

SQL Server 2008 R2: Delete duplicate rows from multiple tables and keep original one

From Dev

Delete multiple rows from multiple tables in mysql using single value

From Dev

How to delete multiple rows from multiple tables using Where clause?

From Dev

MySQL Subtract from multiple rows in one query

From Dev

SQL, How to delete rows from related tables using a query?

From Dev

How to delete rows from three tables - query erro

From Dev

Stored procedure: delete rows from multiple tables with output for every row

From Dev

SQL Select rows and delete/update from dynamic multiple tables

From Dev

Delete multiple tables from a single query by separating from semicolon

From Dev

How to count rows from two tables in one query?

From Dev

How to count rows from two tables in one query?

From Dev

Delete rows from all tables

From Dev

Insert multiple rows from two tables into one table

From Dev

Sqlalchemy single query for multiple rows from one column in one table

From Dev

MySQL delete multiple rows in multiple tables

From Dev

query from multiple tables?

From Dev

SQL Basics: How to get details from multiple tables in one query?

From Dev

SELECT query from one table linked with foreign key to multiple tables

From Dev

Compare columns from multiple tables in one query PHP/SQL

From Dev

Join multiple tables, select counts from different tables and group by one column in one query

Related Related

  1. 1

    Select random rows from multiple tables in one query

  2. 2

    Postgresql delete multiple rows from multiple tables

  3. 3

    Delete rows from multiple tables in a database

  4. 4

    DELETE rows from multiple tables with JOIN in Mysql

  5. 5

    delete from 3 tables with one query

  6. 6

    Query to delete from multiple tables in Access

  7. 7

    Query to delete from multiple tables in Access

  8. 8

    Pulling Multiple Rows from Multiple Tables and Ordering Them Using One MySQL Query

  9. 9

    Delete from multiple related tables on one id?

  10. 10

    SQL Server 2008 R2: Delete duplicate rows from multiple tables and keep original one

  11. 11

    Delete multiple rows from multiple tables in mysql using single value

  12. 12

    How to delete multiple rows from multiple tables using Where clause?

  13. 13

    MySQL Subtract from multiple rows in one query

  14. 14

    SQL, How to delete rows from related tables using a query?

  15. 15

    How to delete rows from three tables - query erro

  16. 16

    Stored procedure: delete rows from multiple tables with output for every row

  17. 17

    SQL Select rows and delete/update from dynamic multiple tables

  18. 18

    Delete multiple tables from a single query by separating from semicolon

  19. 19

    How to count rows from two tables in one query?

  20. 20

    How to count rows from two tables in one query?

  21. 21

    Delete rows from all tables

  22. 22

    Insert multiple rows from two tables into one table

  23. 23

    Sqlalchemy single query for multiple rows from one column in one table

  24. 24

    MySQL delete multiple rows in multiple tables

  25. 25

    query from multiple tables?

  26. 26

    SQL Basics: How to get details from multiple tables in one query?

  27. 27

    SELECT query from one table linked with foreign key to multiple tables

  28. 28

    Compare columns from multiple tables in one query PHP/SQL

  29. 29

    Join multiple tables, select counts from different tables and group by one column in one query

HotTag

Archive