select print_date as pdate,Count (print_date)作为pcount从卡where print_date BETWEEN DATE_SUB(CURRENT_DATE(), INTERVAL 6 DAY) and CURRENT_DATE()分组
********* 在一个条件created_by =祝辞Yii:美元应用→→用户身份;
$rows = (new yiidbQuery())
->select(['print_date AS pdate','count(print_date) as pcount'])
->from('cards')
->andwhere(['between','print_date','2021-03-01','CURRENT_DATE()'])
->andWhere(['created_by'=>Yii::$app->user->identity->id])
->groupBy('print_date')
->all();
当我执行上面的查询我得到的结果,但当我用DATE_SUB('CURRENT_DATE()',INTERVAL 7天)代替20121-03-01我得到一个空数组[0]
$rows = (new yiidbQuery())
->select(['print_date AS pdate','count(print_date) as pcount'])
->from('cards')
->andwhere(['between','print_date','DATE_SUB(CURRENT_DATE(), INTERVAL 6 DAY)','CURRENT_DATE()'])
->andWhere(['created_by'=>Yii::$app->user->identity->id])
->groupBy('print_date')
->all();