5
Good morning.
I have a field on my table called tags
, would like to do a search, where two or three words can be considered.
Example: In the field tags
, I have some words, like "free", "cabins", "audiometer"... with the query below, my result returns empty, even with the word being inside the field.
Like I’m doing:
SELECT *
FROM Produtos
WHERE Tags = 'Audiômetro' OR 'Impedanciômetro' OR 'OEA' OR 'BERA' OR 'Vectonistagmógrafo';
My result only appears if I have ONLY one item in the "tags" field. If I put a phrase, for example, I get no results.
How to proceed?
I had already seen this solution, but since I intend to release 10, 15 tags, I thought it would be less work to put them in one field.
– Hebert Richard Masseno Dias
still returning empty. I did the test below with the
REGEXP
and it worked fine. Thanks for your time! You’re the guy!– Hebert Richard Masseno Dias
It can be some silly detail of syntax, however if there is some error in the answer it is fundamental that I find and correct so as not to leave anything teaching wrong. I’d have to see your code to see if it was my mistake or yours, but I couldn’t do that here in the answer. Qq thing, if you want, leave a link to the Pastebin in the comments that I spy later.
– Bacco
It may even be my mistake here, don’t beat yourself up. Sure, I must have implanted it wrong. Again, thank you very much!
– Hebert Richard Masseno Dias
Anyway, I would recommend thinking about a relationship of tables, instead of storing it in text, because when you have many tags, it starts to complicate. Search for substring is slow, either with regex, like or find_in_set
– Bacco
I understand. This is possible to happen. I will study this possibility.
– Hebert Richard Masseno Dias
Still in the matter of normalize can be interesting to store in the database using Pipes "|" as separator and replace in the view so you can always search with SELECT ... WHERE Tags LIKE `%term|% ...
– user38174