我已使用以下查询获取大于2012的信息,但与日期相比我没有得到正确的数据,请给我正确的查询?MYSQL查询:
SELECT a.invoiceno,
a.invoicerefno,
a.invoicedate,
c.companyname,
a.grandtotal,
a.twempname,
itemdescription,
quantity
FROM twsql_twalldata.t_invoicedet a
INNER JOIN twsql_twalldata.t_salesinv_items b ON a.invoiceno=b.invoiceno
INNER JOIN twsql_twalldata.t_customerdet c ON a.customercode=c.customercode
WHERE a.twempname NOT LIKE '%Auto%'
AND itemdescription LIKE '%AMC%'
OR itemdescription LIKE '%annual maintenance contract%'
AND invoicecancelled=0
AND a.invoicedate > '2012-04-01 00:00:00';
试试这个:
SELECT a.invoiceno,
a.invoicerefno,
a.invoicedate,
c.companyname,
a.grandtotal,
a.twempname,
itemdescription,
quantity
FROM twsql_twalldata.t_invoicedet a
INNER JOIN twsql_twalldata.t_salesinv_items b ON a.invoiceno=b.invoiceno
INNER JOIN twsql_twalldata.t_customerdet c ON a.customercode=c.customercode
WHERE a.twempname NOT LIKE '%Auto%' AND
(itemdescription LIKE '%AMC%' OR itemdescription LIKE '%annual maintenance contract%') AND
invoicecancelled=0 AND DATE(a.invoicedate) > DATE('2012-04-01');
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句