Answer the question
In order to leave comments, you need to log in
Sphinx how to set up a search on two tables?
Hello!
Today I started to study sphinx in order to "attach" it to working projects. I've been struggling for hours with this task, googling doesn't help.
There are two tables:
tbl_articles
-------------------------
id | title | category_id
tbl_categories
------------------------
id | title
source articles : init {
sql_query = SELECT articles.category_id AS pid, articles.id, articles.title \
FROM tbl_categories AS tbl_categories, tbl_articles AS articles \
WHERE tbl_categories.id = articles.category_id \
sql_attr_multi = uint pid from query; SELECT id, category_id FROM tbl_articles
}
Answer the question
In order to leave comments, you need to log in
It has not worked for a long time, but the first value was always id, the rest gets into the search!
the rest (sql_attr_*) are attributes, if you need to add a condition. for example, only by catId = 7, etc.
source articles : init
{
sql_query = SELECT a.`id`, a.`title`, b.`title` as `catTitle` FROM `tbl_articles` AS a LEFT JOIN `tbl_categories` AS b ON b.`id` = a.`category_id`
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question