my tables and data as following,declare @tDirMovie table(cd varchar(50), descrp varchar(200), isCompulsory bit)/*cd is a unique*/insert into @tDirMovie values('01','mission impossible', 'true')insert into @tDirMovie values('02','thor', 'false')insert into @tDirMovie values('03','x-men', 'true')insert into @tDirMovie values('04','batman', 'true')insert into @tDirMovie values('05','hulk', 'false')declare @tMyMovie table(myID varchar(10), tDirMovie_Cd varchar(50))/*@tMyMovie(tDirMovie_Cd) is a foreign key to @tDirMovie(cd)*/--if myID='1925'insert into @tMyMovie values('1925','01')insert into @tMyMovie values('1925','02')--if myID='4474'insert into @tMyMovie values('4474','01')insert into @tMyMovie values('4474','03')insert into @tMyMovie values('4474','04')
-Requirement-I want to check if all movie with IsCompulsory='true' is SELECTED or not1st ruleBased on the data (myID='1925'). The result is all movie with IsCompulsory='true' is NOT SELECTED2nd ruleBased on the data (myID='4474'). The result is all movie with IsCompulsory='true' is SELECTEDHow my if statement look's like?if (.....)Begin print 'The result is all movie with IsCompulsory='true' is SELECTED'EndelseBegin print 'The result is all movie with IsCompulsory='true' is NOT SELECTED'End
Need help to complete my if statement