我有2個表,常見問題和faq_categories ...我有一個加入工作,到目前爲止,我是一個快樂的露營者。chaning在mysql加入
但是......需求的變化,而我必須要改變的加入,但我不知道該怎麼辦呢
下面是當前的代碼,工作得很好:
SELECT faq.* , faq_categories.categoryname
FROM faq
JOIN faq_categories
ON (faq.catid = faq_categories.catid)
到目前爲止,所有的常見問題解答都屬於一個類別......但從現在開始,將會出現不屬於任何類別的常見問題解答......並且使事情複雜化,至少對我而言是這樣。
我該如何改變這段代碼才能顯示沒有catid的faq?
這裏是我的表:
CREATE TABLE IF NOT EXISTS `faq_categories` (
`catid` int(11) NOT NULL AUTO_INCREMENT,
`parentid` int(11) DEFAULT NULL,
`categoryname` varchar(255) NOT NULL,
`categoryname_en` varchar(255) DEFAULT NULL,
`description` text,
`description_en` text,
`metatags` text,
`metatags_en` text,
`sorder` int(11) NOT NULL,
`visible` tinyint(4) NOT NULL,
`categoryphoto` varchar(255) DEFAULT '',
PRIMARY KEY (`catid`),
KEY `parentid_fk` (`parentid`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=204 ;
CREATE TABLE IF NOT EXISTS `faq` (
`faqid` int(11) NOT NULL AUTO_INCREMENT,
`catid` int(11) DEFAULT NULL,
`question` text NOT NULL,
`question_en` text NOT NULL,
`answer` text,
`answer_en` text,
`metatags` text,
`metatags_en` text,
`sorder` tinyint(4) DEFAULT NULL,
`visible` tinyint(4) DEFAULT NULL,
PRIMARY KEY (`faqid`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=6 ;
感謝Michael..that做到了。只要系統允許我這樣做,我會盡快接受你的回答。謝謝。 – Zoran