| |
|
If this is your first visit, be sure to check out the FAQ by clicking the link above.
You may have to register before you can post: click the register link above to proceed.
To start viewing messages, select the forum that you want to visit from the selection below.
|
 |

05-30-07, 12:12
|
|
Registered User
|
|
Join Date: May 2007
Posts: 2
|
|
|
SQL to find if field is low values
|
|
I need assistance with a field in the first five positions is low-values and then has either spaces or values -- I need to get the ones where only the first 5 positions are low values?
|
|

05-30-07, 12:40
|
|
www.gvee.co.uk
|
|
Join Date: Jan 2007
Location: UK
Posts: 10,156
|
|
Fancy posting some example data and what your expect your results to look like?
|
|

05-30-07, 12:53
|
|
Registered User
|
|
Join Date: May 2007
Posts: 2
|
|
|
|
Here is an example of the data in column addr1 pic x(20):
123 Cannon Way
X'0000000000' Nasco place
X'0000000000' Yellow Rd
456 Jamison Ave
In my select I want to get the 2 & 3 data example in my select, when i put the following SQL
Select addr1
,addr2
From TWIP120
Where addr1 = X'00'
I don't get rows 2 & 3 back because my whole data field isn't low values
|
Last edited by Pattio; 05-30-07 at 12:57.
|

05-30-07, 13:35
|
|
www.gvee.co.uk
|
|
Join Date: Jan 2007
Location: UK
Posts: 10,156
|
|
I'm lost in translation...
Code:
Where addr1 = X'00'
This isn't valid SQL.
And what do you mean by "low values"
|
|

06-02-07, 22:01
|
|
Resident Curmudgeon
|
|
Join Date: Feb 2004
Location: In front of the computer
Posts: 12,605
|
|
Quote:
|
Originally Posted by Pattio
I need assistance with a field in the first five positions is low-values and then has either spaces or values -- I need to get the ones where only the first 5 positions are low values?
|
The syntax varies depending on the SQL dialect... What vendor (DB2, Oracle, Microsoft, MySQL, etc) and version (1.2, 10.5, Rockafeller, Tornado, etc) of SQL are you using?
-PatP
|
|

06-10-07, 16:43
|
|
Registered User
|
|
Join Date: Sep 2004
Location: Belgium
Posts: 1,079
|
|
Quote:
|
Originally Posted by Pattio
Select ...
From TWIP120
Where addr1 = X'00'
I don't get rows 2 & 3 back because my whole data field isn't low alues
|
What about
Code:
Select ...
From TWIP120
Where substr(addr1, 1, 5) = X'00'
__________________
--_Peter Vanroose,
__IBM Certified Database Administrator, DB2 9 for z/OS
__IBM Certified Application Developer
__ABIS Training and Consulting
__http://www.abis.be/
|
|

06-11-07, 03:42
|
|
www.gvee.co.uk
|
|
Join Date: Jan 2007
Location: UK
Posts: 10,156
|
|
Code:
Select ...
From TWIP120
Where substr(addr1, 1, 5) = X'00'
Won't you hit syntax errors with the single quotes?
|
|

06-11-07, 05:05
|
|
SQL Consultant
|
|
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,524
|
|
SUBSTR isn't standard sql either
|
|

06-11-07, 05:27
|
|
www.gvee.co.uk
|
|
Join Date: Jan 2007
Location: UK
Posts: 10,156
|
|
Change to a LIKE comparison?
|
|

06-11-07, 15:04
|
|
Registered User
|
|
Join Date: Sep 2004
Location: Belgium
Posts: 1,079
|
|
Still a bit platform-specific, but instead of asking for 'equal to "LOW VALUES"' one could maybe ask for 'smaller than any normal text'.
When the underlying system uses ASCII or UNICODE, and assuming no ASCII values between 1 and 31 are present as first character of the addr1 field, the following would give the wanted rows:
Code:
Select ...
From TWIP120
Where addr1 < ' '
__________________
--_Peter Vanroose,
__IBM Certified Database Administrator, DB2 9 for z/OS
__IBM Certified Application Developer
__ABIS Training and Consulting
__http://www.abis.be/
|
|
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|