OK I think I understand (maybe) what you are saying. Just store the ID then query the ID from the other table using the ID I just posted.
How would you do that? Would it it be something like a foreach loop then check if the ID exists? Does that sound right?