BETWEEN AND NOT BETWEEN Operator in php
SELECT with BETWEEN Operator Syntax :
SELECT column1, column2, column3... FROM table_name WHERE column_name BETWEEN value1 AND value2;
SELECT with NOT BETWEEN Operator Syntax :
SELECT column1, column2, column3...FROM table_name WHERE column_name NOT BETWEEN value1 AND value2;
If we want to select records whose age is BETWEEN 18 to 20 from table name "personal" using BETWEEN Operator as shown below sql query :
SELECT * FROM personal WHERE age BETWEEN 18 AND 20;
If we want to select records whose age is NOT BETWEEN 18 to 20 from table name "personal" using NOT BETWEEN Operator as shown below sql query :
SELECT * FROM personal WHERE age NOT BETWEEN 18 AND 20;
If we want to select records whose id is BETWEEN 2 to 8 from table name "personal" using BETWEEN Operator as shown below sql query :
SELECT * FROM personal WHERE id BETWEEN 2 AND 8;
If we want to select records whose id is NOT BETWEEN 2 to 8 from table name "personal" using NOT BETWEEN Operator as shown below sql query :
SELECT * FROM personal WHERE id NOT BETWEEN 2 AND 8;
If we want to select records whose name is starting from "a" to "k" from table name "personal" using BETWEEN Operator as shown below sql query :
SELECT * FROM personal WHERE name BETWEEN "a" AND "k";
If we want to apply full name whose name is starting from "anil" and "kamal" from table name "personal" using BETWEEN Operator as shown below sql query :
Here below we applied full names in range, it will count only first character of name. For Example, here we have applied "anil" and "kamal", it will consider only "a" and "k", will not consider whole name.
SELECT * FROM personal WHERE name BETWEEN "anil" AND "kamal";
If we want to select records whose date of birth is starting from "1999-01-01" to "1999-06-30" from table name "personal" using BETWEEN Operator as shown below sql query :
SELECT * FROM personal WHERE birth_date BETWEEN "1999-01-01" AND "1999-06-30";
Comments
Post a Comment