C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Communities   Interview   Jobs   Projects   Offshore Development    
Silverlight Tutorials | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Revenue Sharing |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...

New Feature: Community Sites: Create your own .NET community website and start earning from Google AdSense ! It's Free !




Table Data


Posted Date: 05 Sep 2008      Total Responses: 3

Posted By: narendra       Member Level: Silver     Points: 1



hi friends

i have one table in table total 20 records are there like 1,2,3,4,5,6,7,8.........20
i need the records 6,7,8,9,10,11,12,13,14,15,16,17,18

how to write the query





Responses

Author: ANIL PANDEY    05 Sep 2008Member Level: DiamondRating:     Points: 3

hi,

u can use the following query..

select * from tabname where colname Not In (1,2,3,4,5)


Hope this will work for u..


Regards
Anil

Thanks & Regards
Anil Kumar Pandey



Author: Karthikeyan S    05 Sep 2008Member Level: GoldRating:     Points: 3

Hi,

Following there are three queries and you can select one of the option as per your requirement.

Option 1: Using IN condition
SELECT
*
FROM
<TABLE_NAME>
WHERE <COLUMN_NAME> IN (6,7,8,9,10,11,12,13,14,15,16,17,18)

Option 2: Using NOT IN condition
SELECT
*
FROM
<TABLE_NAME>
WHERE <COLUMN_NAME> NOT IN (1, 2, 3, 4, 5, 19, 20)

Option 3: Using BETWEEN condition
SELECT
*
FROM
<TABLE_NAME>
WHERE <COLUMN_NAME> BETWEEN 6 AND 18




Author: http://dotnetvj.blogspot.com    05 Sep 2008Member Level: DiamondRating:     Points: 2

Hi,
I hope you have the answer by now. But may i know why you want to get only those numbers? what made you to choose only those numbers? is there any search critieria? The reason is why i am asking is if you know what is the criteria that you can use to get those numbers then you can apply that criteria on the table directly with out hard-coding the numbers in IN or NOT IN cluase.

generally IN and NOT IN from performance point of view.

Thanks -- Vj
http://dotnetvj.blogspot.com

Thanks -- Vj

http://dotnetvj.blogspot.com



Post Reply
You must Sign In to post a response.
Next : hi frnds please help me its urgent
Previous : math functions
Return to Discussion Forum
Post New Message
Category: SQL Server

Related Messages



dotNet Slackers   BizTalk Adaptors    Web Design


Contact Us    Privacy Policy    Terms Of Use