0

would like to seek your help for deleting rows from multiple tables.

Columns of Table A) indexnum people title

Columns of Table B) indexnum jobtitle status

what I would like to do is delete any rows from two tables, that has a certain index number, which would be accomplished by,

DELETE A WHERE num='1';
DELETE B WHERE num='1';

Can I do this in a single SQL?

I have looked up in other Q&As with recommendations to use INNER JOIN but wasn't able to make up one for my own...

  • Is there any foreign key correlation between the two tables? – nasukkin Feb 20 '18 at 23:28
  • Why don't you create a stored procedure for this? – doganak Feb 20 '18 at 23:37
  • 1
    Tag your question with the database you are using. The generic answer is "cascading delete triggers". – Gordon Linoff Feb 20 '18 at 23:46
  • 1. There aren't any correlation set between these tables 2. Main reason for doing this is because I am using a dataset as an underlying source for a Grid control in C#, and the displayed grid retrieves data from multiple tables. and I need to delete a certain row, not knowing the row originated from, by clicking the "delete" button which calls SqlAdapter.Update command. – Jimin Choi Feb 21 '18 at 01:02
  • see previous/similar answer on deleting multi tables https://stackoverflow.com/questions/48604399/deleting-tables-with-mysqli-multi-query/48604488#48604488 and please keep to the warnings on the answer. – Bobby Axe Feb 21 '18 at 01:05

0 Answers0