0

I need to delete a record from another table after the update of another table .

create table people ( id int identity (1,1) name varchar (50) Available char(3) primary key (id)) create table student ( id int, grade char(1), primary key(id), foreign key(id) references people (id)) people tablae student table id name Available id grade 1 john yes 2 B 2 sam yes if i update Available as 'NO' in sam all the records must delete in student table wich is grade.

29th Dec 2016, 1:36 PM
Duvindu pamaljith
Duvindu pamaljith - avatar
3 odpowiedzi
0
Look up 'Trigger in Sql' or 'Cascading SQL'
29th Dec 2016, 2:41 PM
Andreas K
Andreas K - avatar
0
lowshuen, this is not an automatic executed statement as requested
30th Dec 2016, 8:12 AM
Andreas K
Andreas K - avatar
- 1
UPDATE people SET Available='no' WHERE .... DELETE FROM student WHERE id IN (SELECT id FROM people WHERE Available = 'no')
30th Dec 2016, 7:06 AM
lowshuen