Welcome Guest, Not a member yet? Register   Sign In
between clause
#1

[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
#2

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

Reference: http://dev.mysql.com/doc/refman/5.0/en/c...or_between
#3

[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.
#4

[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');
#5

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

[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
#7

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




Theme © iAndrew 2016 - Forum software by © MyBB