I have the following structure:
tabela (Grupo):
-cd_grupo
-nm_grupo
-ds_filtros -> Aqui armazeno parte do comando SQL utilizado como filtro , para posteriormente atualizar.
I have stored the following information.
cd_grupo | nm_ grupo | ds_filtro
1 | grupo1 | AND (uf = 'PR') AND (genero = 'F')
2 | grupo2 | AND (nasc >= '1990-02-20')
There is another link table where employees are linked according to the group filter.
cd_grupo | cd_funcionario
1 | 14
1 | 19
1 | 35
My question is to update the binding table when the employee's status changes and when a new employee is added.
In this way I know that it does not work, but the idea is this:
SELECT cd_funcionario FROM funcionario WHERE (SELECT ds_filtros FROM grupo)
That would bring the filters "AND (uf = 'PR') AND (gender = 'F')" and add after the WHERE clause
Is there any alternative to storing the filters, or if you have to search all the filters in the group table and apply them to another SQL command, be it REPLACE, UPDATE or INSERT?
I'm using PHP with Mysql.