Questions tagged [multi-table-delete]

10 questions
148
votes
13 answers

Delete all data in SQL Server database

How I can delete all records from all tables of my database? Can I do it with one SQL command or I need for one SQL command per one table?
AndreyAkinshin
  • 18,603
  • 29
  • 96
  • 155
3
votes
2 answers

SQL Delete vs. Cascade

I'm creating a contact management system that records a company's contact details, contact person, campaign, submitted proposals by the company, and donation. One company can have many contact people, can submit many proposals in many campaigns,…
2
votes
4 answers

Multiple delete in a single query

DELETE FROM Table1 WHERE ConditionID=?ConditionID; DELETE FROM Table2 WHERE ConditionID=?ConditionID; DELETE FROM Table3 WHERE ConditionID=?ConditionID; ConditionID is a column present in Table1,Table2,Table3, instead of running 3 times…
Sharpeye500
  • 8,775
  • 25
  • 95
  • 143
2
votes
1 answer

How can I perform multi-table delete in safe mode with binary logging enabled?

Let's pretend, that I have following data structure: DROP TABLE IF EXISTS `A`; DROP TABLE IF EXISTS `B`; DROP TABLE IF EXISTS `C`; CREATE TABLE IF NOT EXISTS `C` ( `ID_C` INT UNSIGNED NOT NULL AUTO_INCREMENT, …
BlitZ
  • 12,038
  • 3
  • 49
  • 68
1
vote
3 answers

Can I delete rows from 2 tables in one single SQL statement?

I have 2 tables one called "REVIEW" and the other "REVIEW_DESCRIPTION" If I do a join to get all the data from both: SELECT * FROM reviews INNER JOIN reviews_description ON reviews.reviews_id=reviews_description.reviews_id WHERE…
sebb
  • 187
  • 1
  • 1
  • 5
1
vote
4 answers

How to delete rows from tables which is referenced each other?

I want to do this: delete from table1 a,table2 b, table3 c where a.col1 = b.col1 and b.col2 = c.col2 and a.co3 <> 8001; But its giving me an error.
SmartestVEGA
  • 8,415
  • 26
  • 86
  • 139
0
votes
1 answer

Delete multitable HSQLDB

Are the multitable DELETE statements supported by HSQLDB? I've done some searches on Google and in the forum, but can't find a topic that deals with this point.
manash
  • 6,985
  • 12
  • 65
  • 125
0
votes
1 answer

Can I use Restaurant and Category Table many to many relation in Product Model using Laravel? and How can I add update Categories_Restaurants table?

Restaurant Table id ---> PK Name Address City Phone Latitude Longitude Categories Table id-->PK section_id ---> FK parent_id ---> for categories and sub-categories category_name--> slug categories_restaurants_table id-> PK category_id -->…
0
votes
1 answer

MySQL - MyISAM multi-table delete (similar to ON CASCADE DELETE)

I'm looking to delete all entries that are referenced by a record, and all the children in different tables as well. If possible I'd like to use a multi-table delete statement as opposed to triggers. For example Table: forms id var 1 foo 2 …
kylex
  • 14,178
  • 33
  • 114
  • 175
0
votes
1 answer

delete from table1,table2,table3 where?

If all tables I want to delete from have the column gamer_id can i do a delete from table1, table2, table3 where gamer_id = 123? or is there a different syntax?
Hailwood
  • 89,623
  • 107
  • 270
  • 423