How to iterate over all the values of a table to check a condition

I think this may be what you are looking for