CodeIgniter Forums
between clause - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: between clause (/showthread.php?tid=11984)



between clause - El Forum - 10-01-2008

[eluser]PHP Programmer[/eluser]
How can I use between clause in my SQL query?
I want to calculate the number of days occur in the dates between 2008-09-20 00:00:00 and 2008-10-01 00:00:00

TIA


between clause - El Forum - 10-01-2008

[eluser]manilodisan[/eluser]
Code:
SELECT * FROM people WHERE height BETWEEN 12 AND 16

Reference: http://dev.mysql.com/doc/refman/5.0/en/comparison-operators.html#operator_between


between clause - El Forum - 10-01-2008

[eluser]PHP Programmer[/eluser]
manilodisan

I want to do it in CodeIgniter. As there is no clause for 'between' in codeigniter. I have searched it in userguide.


between clause - El Forum - 10-01-2008

[eluser]Dready[/eluser]
Hello,

just use the query method of the db object. That gives, with manilodisan example :

Code:
$res = $this->db->query('SELECT * FROM people WHERE height BETWEEN 12 AND 16');



between clause - El Forum - 10-01-2008

[eluser]xwero[/eluser]
Or you could do
Code:
$this->db->where('height','BETWEEN 12 AND 16',FALSE);



between clause - El Forum - 10-01-2008

[eluser]miky4e[/eluser]
[quote author="xwero" date="1222871662"]Or you could do
Code:
$this->db->where('height','BETWEEN 12 AND 16',FALSE);
[/quote]

This is the best solution Wink


between clause - El Forum - 10-01-2008

[eluser]PHP Programmer[/eluser]
thanx to all, it has been solved