Php Mysql查询将在日期返回null
你好,我有这个MYSQL查询Php Mysql查询将在日期返回null,php,mysql,Php,Mysql,你好,我有这个MYSQL查询 public function getInvoices($data,$date1,$date2) { $get = "Select count(*) as count, str_to_date(concat(yearweek(date),'monday'),'%X%V %W') as date, DATE_ADD(str_to_date(concat(yearweek(date),'monday'),
public function getInvoices($data,$date1,$date2)
{
$get = "Select count(*) as count,
str_to_date(concat(yearweek(date),'monday'),'%X%V %W') as date,
DATE_ADD(str_to_date(concat(yearweek(date),'monday'),'%X%V %W'),INTERVAL 6 DAY) as endDate
FROM affilitechargebackResponse
WHERE companyID = ".$data."
AND date >=".$date1."
AND date <=".$date2."
AND process = 1
group by yearweek(date);";
$query = $this->db->query($get);
return $query->result();
}
公共函数getInvoices($data、$date1、$date2)
{
$get=“选择计数(*)作为计数,
str_to_date(concat(yearweek(日期),'monday'),'%X%V%W')作为日期,
日期添加(str_to_DATE)(concat(yearweek(日期),'monday'),'%X%V%W'),间隔6天)作为结束日期
来自affilitechargebackResponse
其中companyID=“.$data.”
日期>=“$date1。”
和date在单引号中使用日期,然后重试
$get = "Select count(*) as count,
str_to_date(concat(yearweek(date),'monday'),'%X%V %W') as date,
DATE_ADD(str_to_date(concat(yearweek(date),'monday'),'%X%V %W'),INTERVAL 6 DAY) as endDate
FROM affilitechargebackResponse
WHERE companyID = ".$data."
AND date >='".$date1."'
AND date <='".$date2."'
AND process = 1
group by yearweek(date);";
$get=“选择计数(*)作为计数,
str_to_date(concat(yearweek(日期),'monday'),'%X%V%W')作为日期,
日期添加(str_to_DATE)(concat(yearweek(日期),'monday'),'%X%V%W'),间隔6天)作为结束日期
来自affilitechargebackResponse
其中companyID=“.$data.”
日期>='“$date1.”
日期和日期>=“$date1。”
日期=“$date1.”
和date试试这个,它会起作用的:
$get = "Select count(*) as count,
str_to_date(concat(yearweek(date),'monday'),'%X%V %W') as date,
DATE_ADD(str_to_date(concat(yearweek(date),'monday'),'%X%V %W'),INTERVAL 6 DAY) as endDate
FROM affilitechargebackResponse
WHERE companyID = ".$data."
AND date >='".$date1."'
AND date <='".$date2."'
AND process = 1
group by yearweek(date);";
$get=“选择计数(*)作为计数,
str_to_date(concat(yearweek(日期),'monday'),'%X%V%W')作为日期,
日期添加(str_to_DATE)(concat(yearweek(日期),'monday'),'%X%V%W'),间隔6天)作为结束日期
来自affilitechargebackResponse
其中companyID=“.$data.”
日期>='“$date1.”
日期$date2的值是多少?您能提供示例数据吗?
AND date >='".$date1."'
AND date <='".$date2."'
$get = "Select count(*) as count,
str_to_date(concat(yearweek(date),'monday'),'%X%V %W') as date,
DATE_ADD(str_to_date(concat(yearweek(date),'monday'),'%X%V %W'),INTERVAL 6 DAY) as endDate
FROM affilitechargebackResponse
WHERE companyID = ".$data."
AND date >='".$date1."'
AND date <='".$date2."'
AND process = 1
group by yearweek(date);";