Ok, I never post on here until I’ve spent days trying to figure it
out on my own.
This one is extremely tough. I will be very suprised and
also in awe of anyone who solves this one.
ALSO NOTE: I am doing this in PHP and don’t care how many queries or loops
I need to make to accomplish this .. so if more than one query or a php loop can
help then by all means please suggest it. Thanks
UPDATE: To simplify this, if you can solve it with availMetals like %White Gold% insetad of like %catFilter.value% I think it will be easier.
I can use PHP loops to accomplish the rest.
Thank you to anyone who takes the time to look.
I have 3 tables with the following fields:
catFilter - (id, catTypeId, value)
products - (id, availMetals)
prodFilter - (id, catFilterId, productId)
And the following Relations
products.id = prodFilter.productId
catFilter.id = prodFilter.catFilterId
I need to get three pieces of data as the
ultimate result:
catFilter.id (also could be prodFilter.catFilterId)
catFilter.value
So far I can get those two… I need the third..
A COUNT OF .. All Products who have an availMetals like
of %White Gold% and also has catTypeId = 1
Here is What the final list would Look Like …
catFilter.value – Product Count
classic - 0
rings - 0
sets - 1
stones - 5
three - 0
halo - 3
etc.. etc…
Here is some sample data for the tables
products
id - availMetals
111 - White Gold
112 - White Gold, Yellow Gold
113 - White Gold
114 - White Gold
115 - White Gold
116 - White Gold, Platinum, Palladium
prodFilter
productId - catFilterId
111 - 43
111 - 12
111 - 48
111 - 47
112 - 12
112 - 51
112 - 48
113 - 12
113 - 51
113 - 48
114 - 12
114 - 51
114 - 48
115 - 12
115 - 48
116 - 12
116 - 51
catFilter
id - catTypeId - value
1 - 1 - Classic
50 - 1 - Rings
47 - 1 - Sets
48 - 1 - Stones
49 - 1 - Three
51 - 1 - Halo
Try something like :