I have a MySQL DB with three tables: categories (can be subcategories), items and item_categories (because item can belong to several categories).
SQL code:
CREATE TABLE `categories` (
`id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
`parent_id` INT NOT NULL ,
`name` TEXT NOT NULL
)
CREATE TABLE `items` (
`id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
`cat_id` INT,
`title` TEXT NOT NULL ,
`price` VARCHAR( 10 ) NOT NULL
)
CREATE TABLE `item_categories` (
`id` INT NOT NULL AUTO_INCREMENT ,
`item_id` INT NOT NULL ,
`cat_id` INT NOT NULL ,
PRIMARY KEY (`id`)
)
So the question is: for a list of categories how to get count of offers?
Where
(1, 2, 3)is a list of categories you’re interested about