I have a site with a two column layout where the left column content depends on the category. However I want it to be subcategory dependable - in a twisted way: the left column should be the same for every subcategory within a category except some specific subcategories (e.g. Plums) that should get their own content:
table subcats
subcat_id | subcat
1 | apples
2 | plums
3 | peaches
table left_column_content
text_id | cat_id | subcat_id | column_text
1 | 8 | 0 | asdfasdfk
2 | 8 | 0 | dfgdfghjk
4 | 8 | 2 | plumplum
3 | 8 | 2 | plumplum
I believe the query should be like this:
SELECT column_text
FROM left_column_content WHERE
CASE WHEN subcat_id = '$subcat_id'
THEN cat_id = '$cat_id' AND subcat_id = '$subcat_id'
ELSE cat_id = '$cat_id' AND subcat_id = '0'
END
Don't tell me, I know - the line (WHEN subcat_id = '$subcat_id') is all wrong and doesn't serve my purpose but it's just a placeholder as I just can't wrap my brains around this seemingly simple problem. If anyone could help, it would be greatly appreciated.