I have 2 tables in my MySQL table: cat and notes.
MySQL for cat
CREATE TABLE IF NOT EXISTS `cat` (
`cat_id` int(11) NOT NULL AUTO_INCREMENT,
`cname` int(11) NOT NULL,
PRIMARY KEY (`cat_id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
MySQL for notes:
CREATE TABLE IF NOT EXISTS `notes` (
`notes_id` int(11) NOT NULL AUTO_INCREMENT,
`title` varchar(50) NOT NULL,
`notebody` varchar(300) NOT NULL,
`cat_id` int(20) NOT NULL,
`approved` int(11) NOT NULL,
PRIMARY KEY (`notes_id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
I like to know how to count how many notes each category have that approved equals to 1. and I want to show categories that have zero notes as category name – 0. I tried left join but it’s leaving all categories that have zero notes.
Try
And