This was the way I found to query my three tables: COUNTRY , CHILDREN and NETBLES using the > 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 tables related using foreign keys
Just to recap, I'm going over the definitions of how my database is again (see the image below):
NotethattheFLHOStableisrelatedtothePARENTtablebycolumnidPAI
,incaseJOSE
isthechildofSEVERINO
andMARIA
isthechildofJOSEFINA
:
Nowthequestionyoudonotwanttoshutup:HowdoIbringthis
id
relationtotheperson'snamebysearchingfortheword'%MATILDE%'
usingtheLIKE
/p>
Example:
MATILDEidFILHOS1
meansthatsheisthedaughterofJOSE
,whoisthechildofSEVERINO
,canyouunderstand?Iwanttodothis"recursion" by searching for nome
, but only those that are related by the primary key id
.