mysql左边连接或全文加入全文搜索结果

时间:2011-07-21 19:57:43

标签: php mysql sql

我有两个表,标题和内容:

headings                           contents

id      title                   p_id  content url  id

现在我有了这个mysql_query:

"SELECT id, title FROM headings WHERE 
  MATCH (title) AGAINST('$query') ORDER BY 
  MATCH (title) AGAINST('$query') DESC"

我想要做的是从标题中获取关联的id之后从内容中选择内容,url(加入?)....然后按p_id升序排序...我很难通过全文搜索和弄清楚我将如何加入表格

1 个答案:

答案 0 :(得分:2)

SELECT h.title, c.contents, c.url
    FROM headings h
        INNER JOIN contents c
            ON h.id = c.id
    WHERE MATCH (h.title) AGAINST('$query') 
    ORDER BY c.p_id