Codeigniter: how to get data between today and last 15 days from database

前端 未结 5 399
谎友^
谎友^ 2021-01-13 00:55

my database table looks like below

| id | user_name | address | contact | date | |----|-----------|---------|---------|----------| | 1 | john | NY

5条回答
  •  情话喂你
    2021-01-13 01:19

    Remove ; semicolon after NOW() function, semicolon is break query so YySql understand another query after semicolon
    this query would work

     $result = $this->db->query('SELECT * FROM '.$table.' 
     WHERE `date` BETWEEN DATE_SUB(NOW(), INTERVAL 15 DAY) AND NOW() AND '.$condition);
    

提交回复
热议问题