I have 3 tables:
TABELA A
ID ID_TABELA_B
1 188
2 189
3 190
4 200
TABELA B
ID ID_TABELA_C
188 22
189 22
190 22
200 23
TABELA C
ID NAME
22 Gato
23 Cão
Table A is linked to table B and table B linked to table C as you can see through the field FK_TABELA_ [x].
It is necessary to update table A where the FK_TABELA_B field is equal to the largest ID of table B, but if the FK_TABELA_C field matches the ID of the 'Cat' in table C, that is 22.
I have to use the term 'Cat' because in principle I do not know the 'Cat' ID, I used 22 just for example.
The result after the query would be:
TABELA A
ID FK_TABELA_B
1 190
2 190
3 190
4 200
The above result is because "190" is the largest ID in table B with the "Cat" ID in table C.