I have the following SQL
$contarperfilclienteinsuficiente = "0";
$sqlxmlperfilclienteinsuficiente = "select
COUNT(CASE WHEN tipo = 0 THEN 1 ELSE NULL END),
COUNT(CASE WHEN tipo <> 0 THEN 1 ELSE NULL END)
from
clientes
where
cliente = '$cliente'
AND status = '2'
AND (disponibilidade <> '0' OR vanual <> '0' OR vtemporada <> '0')";
$rsqlxmlperfilclienteinsuficiente = mysql_query($sqlxmlperfilclienteinsuficiente)
or die ("Banco XML não abre!");
while($rowxmlperfilclienteinsuficiente = mysql_fetch_array($rsqlxmlperfilclienteinsuficiente))
{
$contarperfilclienteinsuficiente = $contarperfilclienteinsuficiente + 1;
}
I need to tell you how many customers have TYPE = 0 and also have availability and vanual and / strong> also zero
Important! The TYPE field is always ZERO to display a record, but if the TYPE field is ZERO DIFFERENT < strong E at least one of availability or vanual or timesheet fields are different from ZERO A record may not be displayed as a result.I have this other SQL that also does not work:
"select
id,disponibilidade,tipo
from clientes
where cliente = '$cliente' AND status = '2' AND tipo = '0' AND (disponibilidade <> '0' OR vanual <> '0' OR vtemporada <> '0')"
Please help me!
See the implemented model!
$sqlxmlperfilclienteinsuficiente = "SELECT
COUNT(1) as TOTAL_CLIENTES
FROM
CLIENTES
WHERE
status = 2
AND
(
( tipo = 0
AND disponibilidade = 0
AND vanual = 0
AND vtemporada = 0
)
OR
( tipo <> 0
AND (disponibilidade <> 0 OR vanual <> 0 OR vtemporada <> 0)
)
)";
$rsqlxmlperfilclienteinsuficiente = mysql_query($sqlxmlperfilclienteinsuficiente)
or die ("Banco XML não abre!");
$num_rowsclienteinsuficiente = mysql_num_rows($rsqlxmlperfilclienteinsuficiente);