5
I’ve been searching the internet and hearing rumors that it is possible to use if else
in Mysql queries but saw nothing concrete about it. Is it even possible? If so, how?
I want to make a query in three distinct tables in search of the column name I have the following query as an example
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%'
That one query will make a query in the three tables PAIS, FILHOS, NETOS
looking for '%MATILDE%'
in the name field
Now I want to do how in this example but with if
SE encontrar '%MATILDE%' na tabela NETOS CONCATENAR
CONCAT(' É FILHA DE ', FILHOS.nome),
CONCAT(' E NETA DE ', PAIS.nome)
SE encontrar '%MATILDE%' na tabela PAIS CONCATENAR
CONCAT(' É MAE DE ', FILHOS.nome),
CONCAT(' E AVO DE ', NETOS.nome)
I want to implement something more or less like this.
Can you explain what kind of query you need to run?
– Sergio
Tell me where the rumor is.
– Maniero
if you search ai gogre se acha @bigown > https://talibamartins.wordpress.com/2007/09/20/if-e-case-no-mysql/
– user45474
ELSE I’ve never seen. I use IF in some responses on the site. One of them is this: http://answall.com/a/127134/70
– Bacco
Possible duplicate of recursive query in related tables using Foreign Keys
– user46523
What differentiates the "grandchildren" in the relationship between parents and children? Because grandchildren can be parents as they can be children. Even I try the same last name.
– Ivan Ferrer