A
A
Alexey Medvedev2016-08-19 15:32:31
MySQL
Alexey Medvedev, 2016-08-19 15:32:31

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

But how to do it with the rest of the tables? I broke my whole head ...
Thank you in advance for your answer.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Melkij, 2016-08-19
@melkij

Relevant search on likes? Hmm.
Take the normal FTS (elasticsearch, shpinx), or at least its built-in mysql likeness dev.mysql.com/doc/refman/5.7/en/fulltext-search.html

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question