Answer the question
In order to leave comments, you need to log in
Is it possible to query SQL (MySQL) to get all data at once?
Is there a way to get data in one request?
https://dl.dropboxusercontent.com/u/19954007/asks/...
I need that when searching for the substring "SHA" I get:
'title' 'tags'
KOLYA
SHA,HA
SASHA OP
of the tags was the searched substring, the second, since the searched substring was found in its header.
i.e., so that the search is performed in pages (by partial match with the title) and by tags (also by partial match) . And, if either the title or one of the tags matched, the entry was returned with the title and ALL of its tags.
I started with GROUP_CONCAT, but I was blown away)))))), of course, it was possible to organize the base differently, but alas .... this is a given )
Thank you
Answer the question
In order to leave comments, you need to log in
SELECT `p`.`title`, GROUP_CONCAT(`t`.`tag` SEPARATOR ',')
FROM `page_tag` AS `pt`
JOIN `tag` AS `t` ON `t`.`id` = `pt`.`tag_id`
JOIN `pages` AS `p` ON `p`.`id` = `pt`.`page_id`
GROUP BY `p`.`id`
More or less like this.
SELECT *(убрать звездочку, перечислить нужные столбцы) FROM Pages as p
LEFT JOIN page_tag as pt ON pt.pageId = p.Id
INNER JOIN tag as t ON t.tag_id = pt.tag_Id
WHERE <Условия фильтрации>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question