Skip to main content

Between and In Operators in SQL

Between Operator

It is used to select values within a range.



Syntax:
SELECT column_name(s)
FROM table_name
WHERE column_name BETWEEN value1 AND value2;


For example:

We have a table like below:

eid name address email mobile joiningdate
1 Ryan Ktm ryan@gmail.com 9874512663 2014/01/24
2 Sunaina Lagankhel s@gmail.com 98745256325 2014/03/12
3 Preeti Budhanagar p@gmail.com 987412321 2014/05/08

Now if you want to find those employees who have joined between '2014/01/01' and '2014/03/30'.

Then simply use the SQL as below:

SELECT * FROM  tbl_employees WHERE  joiningdate   BETWEEN  '2014/01/01'  AND  '2014/03/30' 

IN Operator 
In the above table if you need to list those employees who lives in Lagankhel and Budhanagar then you can use SQL as below:

SELECT * FROM  tbl_employees WHERE  address  IN ('Lagankhel','Ktm')


 

Comments

Popular posts from this blog

CSS List

CSS allows you to customize the lists that can be made with HTML  to the extent that even images can be used as bullet points for unordered lists. CSS List Style Type If you want to use something different from the default numbering of ordered lists, or the bullets/discs of unordered lists, then all you have to do is choose a different style for your lists. CSS allows you to select from a wide variety of different list item shapes. Unordered list styles: square, circle, disc (default), and none Ordered list styles: upper-alpha, lower-alpha, upper-roman, lower-roman, decimal (default), and none Code:

Accessible Forms

Forms aren't the easiest of things to use for people with disabilities. Navigating around a page with written content is one thing, hopping between form fields and inputting information is another. Because of this, it is a good idea to add a number of elements to the form. Labels Each form field should have its own label. The label tag sorts this out, with a for attribute that associates it to a form element:

Join in MySQL

Join clause is used to combine rows from two or more tables depending upon common field between them. There are different kinds of Joins. The most common and useful Join is Inner Join. Inner Join: It will return all rows from multiple tables where the condition is met.