CodeIgniter Forums
[newbie] help with querys - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21)
+--- Thread: [newbie] help with querys (/showthread.php?tid=57903)



[newbie] help with querys - El Forum - 04-24-2013

[eluser]Unknown[/eluser]
hi i want to take all rows from db where date=$today and date=$yesterday and date=$twodaysago

with this i geting $today rows, but how get yesterday and twodaysgo with 1 query im new in ci so help me ;d

Code:
$query = $this->db->get_where('mytable', array('date' =>$today));
return $query->result();



[newbie] help with querys - El Forum - 04-25-2013

[eluser]Sudz[/eluser]
Hi,

Use this
Code:
$this->db->where('date', $today);
$this->db->or_where('date', $yesterday);
$this->db->or_where('date', $twodaysago);

// Produces: WHERE date = $today OR date = $yesterday OR date = $twodaysago