I have a table with this structure
CREATE TABLE `occurrence` (
`occurrence_id` int(10) unsigned NOT NULL auto_increment,
`word_id` int(10) unsigned NOT NULL default '0',
`productId` int(10) unsigned NOT NULL default '0',
PRIMARY KEY (`occurrence_id`)
);
The following query will show me how many times 'something' occurred
for each productId
SELECT productId, count(*) as occurrences
FROM occurrence AS o, word AS w
WHERE o.word_id = w.word_id and word_word = 'something' group by
productId order by occurrences
I want to be able to find out how many times multiple words occur for
each productId.
I want to be able to do something like this.
SELECT productId, count(*) as occurrences
FROM occurrence AS o, word AS w
WHERE o.word_id = w.word_id and word_word = 'something1' order by
occurrences
union
SELECT productId, count(*) as occurrences
FROM occurrence AS o, word AS w
WHERE o.word_id = w.word_id and word_word = 'something2' order by
occurrences
but have it sum the occurrences of 'something1' and 'something2' for
each productId.
I hope that makes sense. If not just ask and I'll clarify it.