0

I want to display the names which is start from 0 to 9. i do not to use reg_exp and like functions.

My data:

select * from emp2;
15326
25371
35371
48615
59718
69718
79718
89718
99718
05326
15326
25371
35371
48615
59718
69718
79718
89718
99718
a19716
b09414
d%5034
!5033
**5031
89718
39718
05326
a19716
b09414
d%5034
!5033
**5031
89718
39718

I used below query to fetch the records.

select * from emp2 where name between '0' and '9';

15326
25371
35371
48615
59718
69718
79718
89718
05326
15326
25371
35371
48615
59718
69718
79718
89718
89718
39718
05326
89718
39718

Result: As i am getting values form 0 to 8.. 9 is not fetching, why?

some more query i tried.

select * from emp2 where name between '+1' and '10';
05326
05326

select * from emp2 where name between '9' and '0';

no rows selected

why this statement is not fetching any of the records

MY expected result: I want to fetch the records whose name starts with 0 to 9.

4

3 に答える 3

3

必要なクエリは次のとおりです。

select *
from emp2
where substr(name, 1, 1) between '0' and '9';

between文字列に適用すると誤解されます。表現:

name between '+1' and '10'

'+'aからa までの文字で始まる名前を探してい'1'ます。数字の場合は、 と で始まる数字に0なり1ます。

表現:

name between '9' and '0'

between の値を順番に並べる必要があるためです。

関連表現:

name between '0' and '9'

近づく。9しかし、別の桁があると何かが欠けてしまいます。

于 2013-08-29T14:18:00.960 に答える
2
SELECT * 
FROM   emp2 
WHERE  SUBSTR(name,1,1)  BETWEEN 0 AND 9
于 2013-08-29T14:12:10.057 に答える