【万能SQL语句】
```
$sql = "SELECT * FROM user"; // select all data
$sql = "SELECT * FROM user WHERE TO_DAYS( NOW( ) ) - TO_DAYS(create_date) <= 1"; //select yesterday data
$sql = "SELECT * FROM user WHERE DATE_FORMAT(create_date,'%Y%m')=DATE_FORMAT(CURDATE(),'%Y%m')"; //select this month data
$query = $this->db->query($sql);
return $query->result();
```
强SQL查询用mysql原生语句的优点是资源多,适用于不同开发语言,如果用codeigniter方式的sql,就只适用于php的codeigniter,资源明显很多,因此难写很多。
参考:
https://www.cnblogs.com/shuilangyizu/p/8805384.html