2
This was the way I found to make a query in my three tables: PARENTS, CHILDREN and GRANDCHILDREN using the operator LIKE:
SELECT `PAIS`.nome,
`FILHOS`.nome,
`NETOS`.nome
FROM `PAIS`, `FILHOS`, `NETOS`
WHERE `PAIS`.nome LIKE '%MATILDE%'
OR `FILHOS`.nome LIKE '%MATILDE%'
OR `NETOS`.nome LIKE '%MATILDE%'
I have another question related to the problem: recursive query in related tables using Foreign Keys
Just to recap, I’m going over the definitions of how my database is doing again (see image below):
Note that the table FLHOS is related to the table PARENTS by the column idPAI, in the case JOSE is the son of SEVERINO and MARIA is the daughter of JOSEFINA:
Now the question that won’t shut up: how do I bring this relationship of
idwith the person’s name through the word search'%MATILDE%'using the operatorLIKE?
Example:
MATILDE idFILHOS 1 means that she is the daughter of JOSE, who is the son of SEVERINO, did you understand? I want to make this "recursion" seeking nome, but bringing only those who are related by the primary key id.



And the grandchildren table? Did not put
– Miguel
That’s a many table for many. I did a little exercise now that is able to help you. You need to create a pivot table that will store id_parent, and id_child only, so you can relate
– Miguel
@Miguel and the first from the bottom up
– user45474
I edited the question because "phpmyadmin" is not a "database", read this to understand the differences: What is the difference between mysql and phpmyadmin?
– Guilherme Nascimento