2
我有兩個不同的表搜索數據和得分
tbl_news(news_id, title, content)
tbl_packages(packaged_id, title, content)
如何這些表與得分和分頁中進行搜索?
我有兩個不同的表搜索數據和得分
tbl_news(news_id, title, content)
tbl_packages(packaged_id, title, content)
如何這些表與得分和分頁中進行搜索?
如果我理解了你,你需要full text search。
這是代碼,它可能會幫助你。
SELECT id, title, content, link FROM (
SELECT news_id AS id, news_title AS title, news_description AS content,
MATCH (news_description, news_title) AGAINST ('$keyword') AS relevance FROM tbl_news
UNION ALL
SELECT package_id AS id, package_title AS title, package_description AS content,
MATCH (package_description, package_title) AGAINST ('$keyword') AS relevance FROM tbl_packages
)temp_sort_table
WHERE relevance >0 ORDER BY relevance DESC LIMIT $offset,$limit