|
database
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Help..........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? Am Sun, 4 Dec 2005 02:07:12 +0700 schrieb Bpk. Adi Wira Kusuma:
Show quote > I ve data like it: select * from table where a >= 6 and a <= 12> > 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? bye, Helmut 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? > > 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. |
|||||||||||||||||||||||