$this->db->select('`tbl_packing_list`.*,((SELECT SUM(`packing_list_quantity`)
FROM `tbl_event_packing_list`
WHERE `event_packing_item` = '.$data['id'].') - ( '
.'SELECT IFNULL(SUM(`tbl_event_packing_list`.`packing_list_quantity`),0 )
FROM `tbl_event_packing_list`
JOIN `tbl_events` ON `tbl_events`.`event_id`=`tbl_event_packing_list`.`event_id`
WHERE ' . $data['date'].' <= DATE_ADD(STR_TO_DATE(`event_end`, "%Y-%m-%d"),INTERVAL 5 DAY))) as avaliableQuantity');
$this->db->get('tbl_packing_list')->row();
答案 0 :(得分:0)
可能是你有一个a)在5天后尝试的where子句:
$data['date'].' <= DATE_ADD(STR_TO_DATE(`event_end`, "%Y-%m-%d"),INTERVAL 5 DAY)) as avaliableQuantity')
答案 1 :(得分:-1)
$ this-&gt; db-&gt; select('((SELECT SUM(packing_list_quantity
)FROM tbl_event_packing_list
WHERE event_packing_item
='。$ data ['id']。' ) - ('
.'SELECT IFNULL(SUM(tbl_event_packing_list
。packing_list_quantity
),0)FROM tbl_event_packing_list
加入tbl_events
ON tbl_events
。event_id
= {{1 } {。tbl_event_packing_list
WHERE'
。 $数据[ '日期']“。 &lt; = DATE_ADD(STR_TO_DATE(event_id
,“%Y-%m-%d”),INTERVAL 5 DAY)和event_end
。tbl_event_packing_list
='。$ data ['id' ]“。 ))as availableQuantity',FALSE);
$这 - &GT; DB-化合物其中( 'event_packing_item',$数据[ 'ID']);
$这 - &GT; DB-&GT;获得( 'tbl_event_packing_list') - &GT;行();