我的查询有问题。请帮助我。
IF (invoicesearch.CLIENTSNAME <> '' AND invoicesearch.FROM <> '' AND invoicesearch.TO <> '' AND invoicesearch.MIN <> '' AND invoicesearch.MAX <> '' AND invoicesearch.STATUS <> '') then
SELECT invoicetable.INVOICENUMBER, invoicetable.INVOICEDATE, invoicetable.DUEDATE, invoicetable.CLIENTSNAME, invoicetable.TOTAL, invoicetable.`STATUS`, Sum(replace(invoicetable.TOTAL,',',''))
FROM invoicetable , invoicesearch
WHERE INVOICETABLE.CLIENTSNAME = invoicesearch.clientname
AND invoicetable.FROM = invoicesearch.FROM
AND INVOICETABLE.TO = invoicesearch.TO
AND MIN(replace(invoicetable.TOTAL,',','')) = invoicesearch.MIN
AND MAX(replace(invoicetable.TOTAL,',','')) = invoicesearch.MAX
AND invoicetable.STATUS = invoicesearch.status
GROUP BY invoicetable.INVOICENUMBER, invoicetable.INVOICEDATE, invoicetable.DUEDATE, invoicetable.CLIENTSNAME, invoicetable.TOTAL, invoicetable.`STATUS`
答案 0 :(得分:0)
对于您使用IF
指定的条件,只需将其添加到WHERE
子句中即可。请随意尝试此查询:
SELECT
invoicetable.INVOICENUMBER,
invoicetable.INVOICEDATE,
invoicetable.DUEDATE,
invoicetable.CLIENTSNAME,
invoicetable.TOTAL,
invoicetable.`STATUS`,
Sum(replace(invoicetable.TOTAL, ',' ,''))
FROM
invoicetable,
invoicesearch
WHERE
INVOICETABLE.CLIENTSNAME = invoicesearch.clientname
AND invoicetable.FROM = invoicesearch.FROM
AND INVOICETABLE.TO = invoicesearch.TO
AND MIN(replace(invoicetable.TOTAL,',','')) = invoicesearch.MIN
AND MAX(replace(invoicetable.TOTAL,',','')) = invoicesearch.MAX
AND invoicetable.STATUS = invoicesearch.status
AND invoicesearch.CLIENTSNAME <> ''
AND invoicesearch.FROM <> ''
AND invoicesearch.TO <> ''
AND invoicesearch.MIN <> ''
AND invoicesearch.MAX <> ''
AND invoicesearch.STATUS <> ''
GROUP BY
invoicetable.INVOICENUMBER,
invoicetable.INVOICEDATE,
invoicetable.DUEDATE,
invoicetable.CLIENTSNAME,
invoicetable.TOTAL,
invoicetable.`STATUS`;