View previous topic :: View next topic |
Author |
Message |
edkir98 Beginner

Joined: 27 Aug 2007 Posts: 102 Topics: 42 Location: Chennai
|
Posted: Tue Sep 23, 2008 7:11 am Post subject: Character comparison |
|
|
Suppose there is a field1 which was defined as an integer in the previous design and now it is defined as char. There is a condition like
Code: | WHERE FIELD1 BETWEEN 100 AND 1000 |
now since this field is changed to a char now, can I give
Code: | WHERE FIELD1 BETWEEN '0100' AND '1000' |
?
Will both the queries return the same result? _________________ Thanks |
|
Back to top |
|
 |
dbzTHEdinosauer Supermod
Joined: 20 Oct 2006 Posts: 1411 Topics: 26 Location: germany
|
Posted: Tue Sep 23, 2008 9:01 am Post subject: |
|
|
F0C1C2C3 is between F0F1F0F0 and F1F0F0F0.
'0ABC' is between '0100' and '1000'
If you don't quit and go work someplace where they know something about db2, suggest you CAST your column to a numeric datatype within the where clause _________________ Dick Brenholtz
American living in Varel, Germany |
|
Back to top |
|
 |
jsharon1248 Intermediate
Joined: 08 Aug 2007 Posts: 291 Topics: 2 Location: Chicago
|
Posted: Tue Sep 23, 2008 2:11 pm Post subject: |
|
|
Good point, dbz. One minor correction though, '0ABC' is not between '0100' and '1000', but the point is still valid because values like '02AB' and '1ABC' are. The other point is format. Leading/trailing zeroes or spaces. Left/right justified. If these are id's, like account number or policy number, the char definition probably makes sense. The op just needs to understand and enforce the rules used to generate the id's. If this post is for true numeric values, follow dbz's advice. |
|
Back to top |
|
 |
dbzTHEdinosauer Supermod
Joined: 20 Oct 2006 Posts: 1411 Topics: 26 Location: germany
|
Posted: Wed Sep 24, 2008 5:08 am Post subject: |
|
|
jsharon1248,
hast Du recht. ich hab' was falsh gesagt! _________________ Dick Brenholtz
American living in Varel, Germany |
|
Back to top |
|
 |
|
|