BETWEEN in Mysql

By | January 18, 2014

This clause will replace greater/less than conditions

Example:

Select * from mydoubts_data

————————————-
|id | jobid | name | salary | age|
————————————-
|1 | 121 | vasanthan| 2000 |31 |
|2 | 122 | John | 3000 |29 |
|3 | 123 | Kiran | 3400 |22 |
|4 | 154 | Raju | 2800 |35 |

Select * from mydoubts_data where age>=29 and age<=31; ------------------------------------- |id | jobid | name | salary | age| ------------------------------------- |1 | 121 | vasanthan| 2000 |31 | |2 | 122 | John | 3000 |29 | above query can be replaced using between as below Select * from mydoubts_data where age between 29 and 31; ------------------------------------- |id | jobid | name | salary | age| ------------------------------------- |1 | 121 | vasanthan| 2000 |31 | |2 | 122 | John | 3000 |29 |