There are two tables:
- Animal owners : information about pet owners
- Animals : in the format "
IDвладельца-IDживотного-приоритет животного"
It is necessary to add in the table.1 the Главное животное field, where the Главное животное IDживотного found in the table.2 by the highest priority is recorded.
The question of how to add a field is not worth it, the question of how to choose an IDживотного with max priority is also.
The question is in what form (procedure, function) and how to carry out a one-time filling of the field thus created for all owners? That is, tell me, please, analogue foreach ID in table1 ....