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
|
| Author: ANIL PANDEY 05 Sep 2008 | Member Level: Diamond | Rating: 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 2008 | Member Level: Gold | Rating: 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 2008 | Member Level: Diamond | Rating: 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
|