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 |
Pace
Constraint Violating Yak Guru
264 Posts |
Posted - 2006-12-11 : 10:43:47
|
Hi All, Im racking my brain with this one... I have this tableId Code -- -------- 1 101010012 101010023 101020014 101020025 601010016 601010027 601020018 601020029 6020100110 6020100211 7010100112 70101002I need to query this table by the following(select id, code from table1)where the first number of Code > 1 and First number of code < 7 but including all after the first number. I thought WHERE Code > '1%' and < etc... however its not right "Impossible is Nothing"  |
|
harsh_athalye
Master Smack Fu Yak Hacker
5581 Posts |
Posted - 2006-12-11 : 10:46:34
|
What is the datatype of Code column?Harsh AthalyeIndia."The IMPOSSIBLE is often UNTRIED" |
 |
|
Pace
Constraint Violating Yak Guru
264 Posts |
Posted - 2006-12-11 : 10:47:11
|
integer"Impossible is Nothing" |
 |
|
Pace
Constraint Violating Yak Guru
264 Posts |
Posted - 2006-12-11 : 10:51:38
|
Got it, Select * from table where code between '1' and '7' + char(255)"Impossible is Nothing" |
 |
|
harsh_athalye
Master Smack Fu Yak Hacker
5581 Posts |
Posted - 2006-12-11 : 10:51:44
|
[code]select * from(select 1 num, 10101001 Code union allselect 2, 10101002 union allselect 3, 10102001 union allselect 4, 10102002 union allselect 5, 60101001 union allselect 6, 60101002 union allselect 7, 60102001 union allselect 8, 60102002 union allselect 9, 60201001 union allselect 10, 60201002 union allselect 11, 70101001 union allselect 12, 70101002) twhere (code/10000000) between 2 and 6[/code]Harsh AthalyeIndia."The IMPOSSIBLE is often UNTRIED" |
 |
|
harsh_athalye
Master Smack Fu Yak Hacker
5581 Posts |
Posted - 2006-12-11 : 10:57:29
|
quote: first number of Code > 1 and First number of code < 7
Do you want to include 1 and 7 as well?Harsh AthalyeIndia."The IMPOSSIBLE is often UNTRIED" |
 |
|
Pace
Constraint Violating Yak Guru
264 Posts |
Posted - 2006-12-11 : 11:04:26
|
ah sorry harsh I should have been a bit more fluid with the question. I used 1 and 7 as testing vals... I wrote a SP so the initial numbers can be placed in by a user instead of having to hardcode it. Thank you very much for your time. Pace =)"Impossible is Nothing" |
 |
|
|
|
|
|
|