我想问一下如何从默认日期到输入日期进行过滤。查询:
SELECT date as Date, COUNT(*) as Transaction, SUM(status=0) as Success
FROM transaction_201504
WHERE date BETWEEN '2015-03-23' AND LIKE '%" .$searchterm. "%';
答案 0 :(得分:0)
我建议在使用LIKE
时不要使用BETWEEN
。你必须把确切的值。
WHERE date BETWEEN '2015-03-23' AND '$searchterm';
其中$searchterm
的格式为yyyy-mm-dd
(例如“2015-03-25”)
答案 1 :(得分:0)
由于您的日期格式为YY-M-D(而不是D-M-YY / M-D-YY),您可以使用字符串比较,如:
SELECT date as Date, COUNT(*) as Transaction, SUM(status=0) as Success
FROM transaction_201504
WHERE date >='2015-03-23' AND date <= $searchterm;
希望它有所帮助。