I am trying the WHERE clause to filter out other data I dont want.
SELECT `post_id`,
MAX(CASE WHEN `meta_key` = \'vlaue_1\' THEN `meta_value` ELSE NULL END
Your WHERE
logic belongs in a HAVING
clause:
SELECT
post_id,
MAX(CASE WHEN meta_key = 'vlaue_1' THEN meta_value END) AS Customer,
MAX(CASE WHEN meta_key = 'value_2' THEN meta_value END) AS DeliveryDate,
MAX(CASE WHEN meta_key = 'value_3' THEN meta_value END) AS DeliveryTime,
MAX(CASE WHEN meta_key = 'value_4' THEN meta_value END) AS DeliveryType
FROM wp_postmeta
GROUP BY post_id
HAVING Customer > 0
ORDER BY post_id;
Note that your current WHERE
clause might technically be valid MySQL:
WHERE 'Customer' > 0
However, this checks whether the string literal 'Customer'
is greater than the value 0. It does not actually check the value of the customer case expression, which is not even available until after group by happens.