And clause on same table for multiple values

Hi, can someone help me to fix this?

SELECT COUNT(*) FROM user_notifications WHERE notification_status = '0' AND notification_sent_to=? AND notification_category = 'ticket reply'AND notification_category= 'groupdoc'

Many thanks

your notification_category cant be equal to ticket reply and groupdoc at the same time. You’ll need an OR/IN clause and GROUP BY with a COUNT in a HAVING clause.

Does your notification_category have a new row for each value, OR comma separated data? It shouldn’t be the latter.

like guelphdad said…

SELECT COUNT(*) FROM user_notifications WHERE notification_status = '0' AND notification_sent_to = ? AND notification_category IN ( 'ticket reply' , 'groupdoc' )

Hi @r937 this worked fine, many thanks :slight_smile:

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.