Skip to content
Advertisement

Sql select count use five condion

i count to some row form my database in five condition use the sql query it’s work with 0 if i put the number more than 0 then it not show any result. please help . it’s work with script

and not work if i put the condition number

my databse https://i.stack.imgur.com/Olyx0.png

Advertisement

Answer

You seem to be trying to count how many records satisfy all the conditions. If so, then your query can be simplified as follows:

The problem with your original code is that COUNT() only surrounds the first CASE expression, not the rest of the conditions; this makes the query inconsistent.

Also, please note that operator && is a non-standard MySQL extension that has been deprecated in recent versions.

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement