Simplify query mysql

0

I would like to know if there is any way to group the search. I have a field that is called $ buski and I would like you to search in all the fields of both one table and the other. So far I am defining it by hand one by one type:

upper(nombre) like upper('%".$buski."%') OR
upper(cif) like upper('%".$buski."%') OR
upper(localidad) like upper('%".$buski."%') 

Is not there a way to put the $ buski just once?

    
asked by Killpe 21.02.2017 в 23:11
source

1 answer

2

It is not very elegant but you could concatenate the three fields:

WHERE UPPER(CONCAT(nombre, cif, localidad)) LIKE UPPER('%".$buski."%') 
    
answered by 21.02.2017 / 23:15
source