sql - Delete statement with a subquery -


i have write delete statement customer table. delete customers have not put in orders. use subquery , exist operator.

im having trouble proper way query should displayed tested , had no luck with. can tell me how fix statement?

         delete customers  dbo.customers                (customerid not exist        (select  customerid                                       dbo.orders                            customerid = ordersid)) 

your syntax using exist operator off, although general idea in right direction:

delete  dbo.customers        not exists (select *                            dbo.orders                           dbo.customers.customer_id =                                  dbo.orders.customer_id)   

Comments

Popular posts from this blog

java - Spring Data JPA: Why findOne(id) executing delete query internally? -

python - Mongodb How to add addtional information when aggregating? -

java - Incorrect order of records in M-M relationship in hibernate -