-2
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 him to count how many clients have the TYPE = 0 and also have the fields availability And vanual And vtemporada also zero
Important! Always the field TYPE IS PARAMOUNT TO BE ZERO to display a record, but if the field TYPE is non-zero And at least one of the camps availability OR vanual OR vtemporada are different from ZERO, NO record may 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')"
Help me please!
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);
The query is to return the total of customers, right? But I noticed that you pass a customer ( $customer), which would restrict the universe to this customer only.
– Márcio Lordelo
that’s right!!!!! Give me a hand in restructuring this second SQL I posted.
– Gladison Neuza Perosini
Okay, so you want to return the total of customers, where the type is equal to zero and the availability, the vanual and the vtemporada can not be different from zero, is that right? I was in doubt regarding these fields (availability, vanual and vtemporada)
– Márcio Lordelo
@Márciolordelo It has to return record if the field type is equal to zero and if all fields availability, vanual and vtemporada are zero. But... will not return record if the capo type is non-zero and also if any of the fields availability, vanual and vtemporada are different from zero.
– Gladison Neuza Perosini
Instead of making more than one post with the same problem, you can edit the existing post and add the details that were missing for a suitable solution. The ideal is to already make the initial posting with the maximum details.
– Bacco