php - Select where a value present -
first database example:
id, product_id, cat, name, value -------------------------------- 1,1,algemeen,processor,2 ghz 2,1,algemeen,geheugen,4 gb 3,2,algemeen,processor,3 ghz 4,2,algemeen,geheugen,4 gb 5,3,beeldscherm,inch,22" 6,3,beeldscherm,kleur,zwart 7,3,algemeen,geheugen,3 gb 8,3,algemeen,processor,3 ghz
i want 1 query select follow id's: 1,2,3,4,7,8
because cat = algemeen , name = processor these products. id 5,6 present product 3.
so, entry's (cat , name) present products (product_id) have selected.
the database contains 80.000 entry's lot of diffrent cat's, name's , value's.
is possible 1 query or php necessary? how do this?
my apologies bad english.
i think mean, show records combination of (cat, name) present in product_ids, right?
select t.id, t.product_id, t.cat, t.name, t.value ( select cat, name tbl group cat, name having count(product_id) = count(distinct product_id) ) p join tbl t on t.cat = p.cat , t.name = p.name
Comments
Post a Comment