Hi there, i have a small database, and 3 tables there. Also there is a "many to many" connection. Look at this:
CREATE TABLE `categories` (
`id` int(11) NOT NULL,
`Name` varchar(45) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8
CREATE TABLE `products` (
`id` int(11) NOT NULL,
`Products` varchar(45) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8
middle table...
CREATE TABLE `category_product` (
`id_category` int(11) NOT NULL,
`id_product` int(11) NOT NULL,
PRIMARY KEY (`id_category`,`id_product`),
KEY `fk_Category` (`id_category`),
KEY `fk_Product` (`id_product`),
CONSTRAINT `fk_Category` FOREIGN KEY (`id_category`) REFERENCES `categories` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
CONSTRAINT `fk_Product` FOREIGN KEY (`id_product`) REFERENCES `products` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB DEFAULT CHARSET=utf8
Please explain how to do queries like "Select all products of x category" or "Add new category and products there"...How to do that?