Re: ALLTRIM( ) in SQL statement
- From: "Anders Altberg" <anders.altberg>
- Date: Mon, 12 Mar 2007 21:33:06 +0100
Alltrim " " equals the empty string which in the logic of SQL is equal to
any value.
-Anders
"David" <David.Aman@xxxxxxxxx> wrote in message
news:1173708844.491299.316220@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
On Mar 11, 11:46 pm, Gene Wirchenko <g...@xxxxxxxx> wrote:
"David" <David.A...@xxxxxxxxx> wrote:
Given the following table:
CREATE TABLE mytable (subject C(10), unit C(10))
INSERT INTO mytable (subject, unit) VALUES ('algebra1',' ')
INSERT INTO mytable (subject, unit) VALUES ('algebra1','1')
INSERT INTO mytable (subject, unit) VALUES ('algebra1','10')
I tried the following SQL statement:
SELECT subject, unit, COUNT(unit) as unitcount ;
FROM mytable ;
WHERE INLIST(unit,'10') ;
GROUP BY subject, unit
The results told me correctly that there was 1 value of '10' in the
table.
===================
Question: Why does the same SQL statement with an added ALLTRIM in
the
WHERE clause result in a response consisting of 3 rows?
SELECT subject, unit, COUNT(unit) as unitcount ;
FROM mytable ;
WHERE INLIST(ALLTRIM(unit),'10') ;
GROUP BY subject, unit
I think you need to look at set ansi.
Sincerely,
Gene Wirchenko
Computerese Irregular Verb Conjugation:
I have preferences.
You have biases.
He/She has prejudices.- Hide quoted text -
- Show quoted text -
Hi, Gene, thanks for your reply...
Here is what I don't think I'm understanding. With SET ANSI OFF, I
get the expected response of 1 value of "10" (i.e., one row in the
query result) when I run this SQL:
SELECT subject, unit, COUNT(unit) as unitcount ;
FROM mytable ;
WHERE INLIST(unit,'10') ;
GROUP BY subject, unit
But (with SET ANSI OFF, still), when I simply add an ALLTRIM( )
function,
I get three row in the results consisting of:
1 instance of (blank)
1 instance of "1"
1 instance of "10"
Here's the SQL:
SELECT subject, unit, COUNT(unit) as unitcount ;
FROM mytable ;
WHERE INLIST(ALLTRIM(unit),'10') ;
GROUP BY subject, unit
I'm a little confused, but I guess my question is, why does ALLTRIM( )
have this effect?
Thanks,
David
.
- Follow-Ups:
- Re: ALLTRIM( ) in SQL statement
- From: David
- Re: ALLTRIM( ) in SQL statement
- References:
- ALLTRIM( ) in SQL statement
- From: David
- Re: ALLTRIM( ) in SQL statement
- From: Gene Wirchenko
- Re: ALLTRIM( ) in SQL statement
- From: David
- ALLTRIM( ) in SQL statement
- Prev by Date: Re: filesystemobject
- Next by Date: Saving Docked form position
- Previous by thread: Re: ALLTRIM( ) in SQL statement
- Next by thread: Re: ALLTRIM( ) in SQL statement
- Index(es):
Relevant Pages
|