Hi
I have 2 tables, faq and faq_categories…i have a join that work, and so far, I was a happy camper.
But…requirements change, and i have to change the join, but i don’t know how to do it
Here is the current code that works just fine:
SELECT faq.* , faq_categories.categoryname
FROM faq
JOIN faq_categories
ON ( faq.catid = faq_categories.catid)
So far, all faq belongs to one category…but from now on, there will be faq which will not belonng to any category…and that complicate things, at least for me.
How should I change this code in order to display the faq which does not have catid?
Here are my tables:
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 ;
Any help will be deeply appreciated.
Regards,Zoreli