How to create temp table from tags?

heraisu

New Member
I have a \[code\]product_table\[/code\] with a \[code\]product_id\[/code\] among several other fields.I am creating a \[code\]tag_table\[/code\] with 2 fields, \[code\]tag_id\[/code\] and \[code\]tag_name\[/code\].The tags could be anything like "silver" or "penn state" etc.I am also creating a \[code\]product_tag_map\[/code\] table with \[code\]product_id\[/code\] and \[code\]tag_id\[/code\] in order to map a product to any number of tags.If I wanted to create a category that contained all products tagged as "silver", "necklace", "diamond". But also exclude any product tagged as "initial", "journey"(Obviously I would use the tag_id not tag_name, so products with tags [2,4,5] that do not have tags [3,6])How could a create a temporary product table and populate it with the matching products?updatehere is my product_tag_map table:\[code\]CREATE TABLE `product_tag_map` ( `product_tag_map_id` int(11) NOT NULL auto_increment, `tag_id` int(11) NOT NULL, `product_id` int(11) NOT NULL, PRIMARY KEY (`product_tag_map_id`), UNIQUE KEY `tag_id` (`tag_id`,`product_id`), KEY `tag_id_2` (`tag_id`)) ENGINE=MyISAM AUTO_INCREMENT=7897 DEFAULT CHARSET=utf8\[/code\]Note: I am not using \[code\]product_tag_map_id\[/code\] for anything. I am just in the habit of giving each table a primary key like so. So If I should remove it thats fine.
 
Back
Top