Home All Groups Group Topic Archive Search About
Author
3 Dec 2005 7:07 PM
Bpk. Adi Wira Kusuma
I ve data like it:

a            b
------  ---------
1            4
5            7
8            10
11           15
16            18

I wanna select data between 6 - 12. so data is showed like it

a            b
------  ---------
5            7
8            10
11           15

How is the code to select its data?

Author
3 Dec 2005 7:47 PM
helmut woess
Am Sun, 4 Dec 2005 02:07:12 +0700 schrieb Bpk. Adi Wira Kusuma:

Show quote
> I ve data like it:
>
> a            b
> ------  ---------
> 1            4
> 5            7
> 8            10
> 11           15
> 16            18
>
> I wanna select data between 6 - 12. so data is showed like it
>
> a            b
> ------  ---------
> 5            7
> 8            10
> 11           15
>
> How is the code to select its data?

select * from table where a >= 6 and a <= 12

bye,
Helmut
Author
4 Dec 2005 1:12 AM
Brian Selzer
select a, b from tableName where (a >= 6 and a <= 12) or (b >= 6 and b <=
12)
Show quote
"Bpk. Adi Wira Kusuma" <adi_wira_kus***@yahoo.com.sg> wrote in message
news:u%23qa%23DE%23FHA.1444@TK2MSFTNGP10.phx.gbl...
>I ve data like it:
>
> a            b
> ------  ---------
> 1            4
> 5            7
> 8            10
> 11           15
> 16            18
>
> I wanna select data between 6 - 12. so data is showed like it
>
> a            b
> ------  ---------
> 5            7
> 8            10
> 11           15
>
> How is the code to select its data?
>
>
Author
4 Dec 2005 3:07 AM
--CELKO--
SELECT a, b FROM Foobar
WHERE a BETWEEN  6 AND 12
   OR b BETWEEN  6 AND 12;

Use the BETWEEN because (1) it is easier for human to read and maintain
(2) some optimizers with B-tree indexes can use the ranges -- in
fairness, if they are that smart, they can use the "3GL style"  (a >= 6
and a <= 12) to convert it to the BETWEEN optimization.

AddThis Social Bookmark Button