I'm working on a trigger action (part of it pictured below) using an IF THEN logic where lots of data are inserted into various tables when a comparison is true versus not being inserted when a comparison is false. It works great when the comparison is simple, such as 1 equals 1 versus 1 equals 2. But what I want to compare is a student_id being inserted versus a student_id in a different table. The logic I need is: If the student_id being inserted in table A is not in table B then all of the insertions will occur. If the student_id being inserted in table A is already in table B then none of the insertions will occur.
My problem is figuring out how to create this field comparison between student_id in what is being inserted and student_id in another table. This is what I have been trying and it doesn't work. I've also tried putting in joins but that hasn't worked either. I've tried not using TOP in each select but then I get an error message. I don't know where to go from here.
You can post now and register later.
If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.
Question
DavidwDavis
I'm working on a trigger action (part of it pictured below) using an IF THEN logic where lots of data are inserted into various tables when a comparison is true versus not being inserted when a comparison is false. It works great when the comparison is simple, such as 1 equals 1 versus 1 equals 2. But what I want to compare is a student_id being inserted versus a student_id in a different table. The logic I need is: If the student_id being inserted in table A is not in table B then all of the insertions will occur. If the student_id being inserted in table A is already in table B then none of the insertions will occur.
My problem is figuring out how to create this field comparison between student_id in what is being inserted and student_id in another table. This is what I have been trying and it doesn't work. I've also tried putting in joins but that hasn't worked either. I've tried not using TOP in each select but then I get an error message. I don't know where to go from here.
Thanks for any help!
David Davis
Link to comment
Share on other sites
4 answers to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.