-2

This question already has an answer here:

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


  • 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
  • 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
  • Oh. Am sorry. @teeyo - javababy
  • It's okay, I'll vote up to remove the down vote ;) - teeyo
  • soon i will get the answer and will post here @teeyo - javababy

1 답변


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.

Ref


  • No. Am getting error like "incorrect syntax near ," - javababy
  • post your Query - Parth Akbari
  • Am asking through mobile. I can't post it. But I have implemented the same thing only. @ Parth Akbari - javababy

Linked


Related

Latest