It's not a secret anymore!
The moose likes JDBC and Relational Databases and the fly likes How to use where with between clause Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "How to use where with between clause" Watch "How to use where with between clause" New topic

How to use where with between clause

Jeetendra S Ahuja

Joined: Feb 11, 2012
Posts: 7
select SUM(fuel_bus) from fuel between date="2011-03-12" and date="2011-0
3-15" where busno=2;//
Above mentioned is query for which i am getting mysql syntax error
fuel_bus=column name that stores float fuel qty values(say 18.6)
fuel=DB name
date=column name, that specifies date on which fuel entry is done
busno=busno for which date wise fuel qty. is feeded
NOw what i want is to calculate fuel qty. from desired date to desired date with respect to specific busno.
select busno,SUM(fuel_bus) from fuel where busno=2;,this query is running,how to integrate between clause with it...
Martin Vajsar

Joined: Aug 22, 2010
Posts: 3733

Try to google up MySQL between syntax. One of the top links leads to MySQL documentation with all proper details of its use. To help you get faster on track: the BETWEEN keyword is part of an expression which must go into the WHERE clause and can be combined with other conditions using usual boolean operators, such as AND and OR.
I agree. Here's the link:
subject: How to use where with between clause
It's not a secret anymore!