I have two tables:
#result - has fields unit_number, rule_id
tesr - has field rule_id
In both tables, the rule_id can be duplicate. What I need to do is determine if table #result has as many occurences of the same rule_id as appear in table tesr for a particular unit number. If it does not, all rows with that rule_id should be deleted.
For example, table tesr has 3 rows in it with rule_id = 12 for unit_number 1.
Case 1: table #result also has 3 rows in it with rule_id = 12 for unit_number 1 - do nothing.
Case 2: table #result has 2 rows in it with rule_id = 12 for unit_number 1. Delete both of these rows.
I'm having trouble using count(*) and getting the syntax right...help please?
#result - has fields unit_number, rule_id
tesr - has field rule_id
In both tables, the rule_id can be duplicate. What I need to do is determine if table #result has as many occurences of the same rule_id as appear in table tesr for a particular unit number. If it does not, all rows with that rule_id should be deleted.
For example, table tesr has 3 rows in it with rule_id = 12 for unit_number 1.
Case 1: table #result also has 3 rows in it with rule_id = 12 for unit_number 1 - do nothing.
Case 2: table #result has 2 rows in it with rule_id = 12 for unit_number 1. Delete both of these rows.
I'm having trouble using count(*) and getting the syntax right...help please?