IT Community - Software Programming, Web Development and Technical Support

In the WHERE clause what is BETWEEN and IN?

This is a discussion on In the WHERE clause what is BETWEEN and IN? within the Database Support forums, part of the Web Development category; In the WHERE clause what is BETWEEN and IN?...


Go Back   IT Community - Software Programming, Web Development and Technical Support > Web Development > Database Support

Register FAQ Members List Calendar Mark Forums Read
  #1 (permalink)  
Old 07-25-2007, 05:41 AM
bluesky bluesky is offline
D-Web Analyst
 
Join Date: Jun 2007
Posts: 201
bluesky is on a distinguished road
Question In the WHERE clause what is BETWEEN and IN?

In the WHERE clause what is BETWEEN and IN?
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 07-25-2007, 07:27 AM
priyan priyan is offline
D-Web Sr.Programmer
 
Join Date: Mar 2007
Posts: 133
priyan is on a distinguished road
Default Re: In the WHERE clause what is BETWEEN and IN?

Hi,

We can use BETWEEN .. AND condition where we dont know the actual search values, so we can
use range of values that satisfies the condition.

fox example, if want to fetch the employee details who earn more than 10000 and not more than
20000, in this situation we can deploy BETWEEN.. AND condition.

Quote:
Here we have the table 'emp'-

SELECT * FROM emp;
---------------------------------------
emp_id emp_name emp_sal
---------------------------------------
1 John 15000
2 Smith 1500
3 Mike 10000
4 rAj 1500
---------------------------------------

SELECT * FROM emp WHERE emp_sal BETWEEN 10000 AND 20000;
---------------------------------------
emp_id emp_name emp_sal
---------------------------------------
1 John 15000
3 Mike 10000
---------------------------------------
Whereas in IN() condition we must know the search key values, here we are not using range
values but the actual search values with comma seperator.

Look at the below given query, this will return the employees who earn 1500 and 10000 salary.
Quote:
SELECT * FROM emp WHERE emp_sal IN(1500,10000);

Quote:
------------------------------------
emp_id emp_name emp_sal
------------------------------------
2 Smith 1500
3 Mike 10000
4 rAj 1500
------------------------------------
Hope this is clear !
__________________
Keep smiling...
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 08-07-2007, 05:24 AM
S.Vinothkumar S.Vinothkumar is offline
D-Web Genius
 
Join Date: May 2007
Posts: 1,061
S.Vinothkumar is on a distinguished road
Default Re: In the WHERE clause what is BETWEEN and IN?

BETWEEN supplies a range of values while IN supplies a list of values.
__________________
S.VinothkumaR
Behind me is infinite power,
Before me is Endless Possibility,
Around me is Boundless Opportunity,
Why should I fear!
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
What is the length(picture clause)? S.Vinothkumar Database Support 1 10-30-2007 01:17 AM
finally clause of a try-catch-finally statement vigneshgets Java Programming 2 08-16-2007 07:35 AM
What is the difference between a HAVING CLAUSE and a WHERE CLAUSE in SQL Server? mobilegeek Database Support 2 08-07-2007 08:04 AM
If I return out of a try/finally in C#, does the code in the finally-clause run? H2o C# Programming 1 07-22-2007 11:27 PM


All times are GMT -7. The time now is 04:50 AM.


Copyright ©2004 - 2007, DiscussWeb. All Rights Reserved.

SEO by vBSEO 3.0.0