I am using ms SQL server. I have 2 tables. Table a and b. Table 'A' contains col 'A' and col 'B'(foreign key) and table 'B' contains details relating to that col 'B'.I want to delete two tables based on col 'A' now. Please help me out of this
Asked
Active
Viewed 101 times
-2
-
I could nt get anything from that. That's why posting this qs.if u have ans jus tell me. Don't under rate the qs @teeyo – javababy Dec 26 '14 at 10:28
-
I'm sorry if you couldn't find an answer in that link, but I'm not the one who under rated the question. – teeyo Dec 26 '14 at 10:35
-
Oh. Am sorry. @teeyo – javababy Dec 26 '14 at 11:32
-
It's okay, I'll vote up to remove the down vote ;) – teeyo Dec 26 '14 at 11:34
-
Boss. Ur crazy :) @teeyo. The prblm is if qs is under rated then I can't ask more qs. – javababy Dec 26 '14 at 11:42
-
yup feel you bro, I have the same issue in this account :/ it said I need more points to be able to ask again, all because I had 3 votes down on one of my questions... anyway good like with your delete ;) – teeyo Dec 26 '14 at 11:57
-
1soon i will get the answer and will post here @teeyo – javababy Dec 27 '14 at 05:09
1 Answers
0
DELETE T1, T2 FROM T1 INNER JOIN T2 ON T1.key = T2.key WHERE condition
Notice that you put table names T1 and T2 between DELETE and FROM. If you omit the T1 table, the DELETE statement only deletes records in the T2 table, and if you omit the T2 table, only records in the T1 table are deleted.
The join condition T1.key = T2.key specifies the corresponding records in the T2 table that need be deleted.
The condition in the WHERE clause specifies which records in the T1 and T2 that need to be deleted.
Parth Akbari
- 641
- 7
- 22
-
-
1Am asking through mobile. I can't post it. But I have implemented the same thing only. @ Parth Akbari – javababy Dec 26 '14 at 11:43