Welcome Guest, Not a member yet? Register   Sign In
Return No of rows as Days in between
#1

(This post was last modified: 04-13-2022, 02:48 AM by lazyme114. Edit Reason: update )

Hi all, I am doing something like this:- 
PHP Code:
    $query $this->db->where(array(
        'user_id' => $user_id,
        'date(start) >=' => $start_date,
        'date(end) <=' => $end_date
    
))->order_by('start''asc')->get($table)->result(); 

It is working fine. But I want it to return a single row for each days between start and end even if data doesn't exists.
Reply
#2

group by date
Reply
#3

(This post was last modified: 04-13-2022, 02:50 AM by lazyme114.)

(04-13-2022, 02:47 AM)badger Wrote: group by date
it would have worked. but I want data even if that days data doesn't exists. maybe an empty row or something like that.
Reply
#4

Found New Way 
PHP Code:
      SELECT FROM bf_attendance where checkin >  2022-03-15 interval 1 month 

but still if no data no row..
Reply
#5

You can't pull data from MySQL which doesn't exist. If it's that important I would loop through the returned data and add a blank record/object/array when I find an empty date,
Reply
#6

(04-13-2022, 01:51 PM)JustJohnQ Wrote: You can't pull data from MySQL which doesn't exist. If it's that important I would loop through the returned data and add a blank record/object/array when I find an empty date,

Currently, I am doing exactly that but, Its for a monthly report and I have to loop through employee first then the sql query comes. If I have 30 employee I have to run 900 query in average. So you see my problem right. I want something that will take less time and load faster.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB