Answer the question
In order to leave comments, you need to log in
How to select and search three tables in MySQL?
Actually I write the search for goods for the site. The search should be as relevant as possible. There are many tables that are completely abstracted from each other.
That is, for each type of goods there is a table with the fields name and html (full description with WYSIWYG markup).
The search string can consist of many words. For one table, everything is super, I make a query like this:
SELECT *, (
IF (tb_table1.name LIKE '%Ляля лала%', 2, 0) +
IF (tb_table1.name LIKE '%Ляля%', 1, 0) +
IF (tb_table1.name LIKE '%лала%', 1, 0) +
IF (tb_table1.html LIKE '%Ляля лала%', 2, 0) +
IF (tb_table1.html LIKE '%Ляля%', 1, 0) +
IF (tb_table1.html LIKE '%лала%', 1, 0)
) AS points FROM tb_table1 ORDER BY points DESC LIMIT 20
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question