1
我有三個表:PHP的MySQL三人離開join方法
文章:
|id|title|timestamp|......
group_tags:
|id|content_id|tags_id
tags_name:
|id|name|
我需要列出文章標題與任何標籤ID:
function _tags_search_($id,$type){
$DB_QUERY = mySqli::f("SELECT title FROM " . ARTICLES . " LEFT JOIN " . POSTS_TAGS . " ON " . ARTICLES . ".id = " . POSTS_TAGS . ".content_id WHERE
" .POSTS_TAGS . ".tags_id = ? AND approved = 1 ORDER BY timestamp DESC LIMIT 12", $id);
foreach($DB_QUERY as $row){
$data[] = $row;
}
return $data;
}
這對我有用,並顯示文章標題列表。
但我需要在另外的標籤ID顯示標籤名稱列出標題是這樣的:
Search result for : Linux
我有兩個辦法:
三人離開,如果真如何連接方法()
獲取顯示標籤名稱的另一個查詢。
我覺得three join
是更好更快發展。如何使用three join
方法顯示標籤名稱?