Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
johnstern
Yak Posting Veteran
67 Posts |
Posted - 2007-04-26 : 18:25:42
|
| I am trying to get all the fields that start with number(s)is there a better way to acomplish this than the way I am doing it now ? select * from mytable where word like '1%' and word like '2%' andword like '3%' andword like '4%' andword like '5%' andword like '6%' andword like '7%' andword like '8%' andword like '9%' andword like '0%' |
|
|
Lamprey
Master Smack Fu Yak Hacker
4614 Posts |
Posted - 2007-04-26 : 18:30:38
|
This should do the same thing and be a little more compact:select * from mytable where word LIKE '[0-9]%' -Ryan |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2007-04-26 : 18:30:50
|
like '[0-9]%' KH |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2007-04-26 : 18:32:37
|
"This should do the same thing"Actually it does not. The "like '1%' and word like '2%' and . . ." would return no result  KH |
 |
|
|
johnstern
Yak Posting Veteran
67 Posts |
Posted - 2007-04-26 : 18:32:46
|
| thank you, very much, first time I use this forum and my two questions got answered within minute. I appreciate it |
 |
|
|
johnstern
Yak Posting Veteran
67 Posts |
Posted - 2007-04-26 : 18:34:15
|
quote: Originally posted by khtan
"This should do the same thing"Actually it does not. The "like '1%' and word like '2%' and . . ." would return no result  KH
ok, now I am comfused ... sorry |
 |
|
|
johnstern
Yak Posting Veteran
67 Posts |
Posted - 2007-04-26 : 18:35:35
|
| ok my bad ya in my original sample I should have say OR not and |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-04-26 : 18:39:10
|
| Any single can't both start with 1 AND 2...Peter LarssonHelsingborg, Sweden |
 |
|
|
Lamprey
Master Smack Fu Yak Hacker
4614 Posts |
Posted - 2007-04-26 : 19:01:54
|
quote: Originally posted by khtan
"This should do the same thing"Actually it does not. The "like '1%' and word like '2%' and . . ." would return no result  KH
Hehe, I went with the requirement: "I am trying to get all the fields that start with number(s)." Not the actual code. :) |
 |
|
|
|
|
|