MySQL Connector - Unidentified Syntax Error in WHERE Clause

Hey everyone,

I permanently do get an error with my Database connection and I tried everything I know, so hopefully you guys can help: I do have a connection to a MySQL table with data about my products. I’m trying to calculate a matching score dynamically in my query between what is specified in the UI and what is in the backend. I do need some columns just to calculate my matching score and some as conditions to filter out certain products initially. ATM a simplified version of my query looks like this:

        product_name, gender_female, gender_male, age_18_22, product_category,
        (CASE WHEN ? = 'female' THEN gender_female ELSE 0 END) +
        (CASE WHEN ? = 'male' THEN gender_female ELSE 0 END) +
        (CASE WHEN ? = '18 - 22' THEN age_18_22 ELSE 0 END)) AS matching_score
    (product_category = ? OR ? = "")
    product_name, gender_female, gender_male, age_18_22, product_category

However, I always get the same syntax error around the WHERE clause and the GROUP BY clause, without further specification. I hope someone of you knows the specifics of MySQL, as I am not too proficient with it. The original query is a lot longer, could this maybe be the issue? Thanks for your help!