1
I intend to make an SQL query where WHERE
has 2 situations, example:
SELECT * FROM products WHERE name = "%Explosion%" OR tag = "%Explosion%"
In this consultation I would specify that, first the consultation checks whether there is any product under the name of explosion
if there were to stop there and return the result without searching tag
if it also exists, but if not found in the name
the query would search in tag
.
I researched ways to do this and the only way that came to me is to make 2 queries. Doing the research first in name
and check if anything returns and then do in tag
if name
return nothing.
Perhaps using the Cláusula join
along with the Cláusula outer
should be able to but could not understand the use of Outer well to develop this correct query.
Someone would have an idea to do this in just 1 consultation without having to juggle with 2?
I use Mysql, worked perfectly using this way you commented. As was an example I used to explain the doubt I used the
=
but really in the system I use theLIKE
– Anorak