How do I structure the where clause to select rows whose data contains spaces?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am trying to execute this INSERT INTO statement, and it fails when I specify a column that includes a space, such as "L GM", however when the column data contains no spaces as in "LGM" the query executes fine

SELECT TargSrt.opt_symbol AS FirstOfopt_symbol, TargSrt.Ticker, TargSrt.imp_volat AS Hvolat, TargSrt.strike AS FirstOfstrike, TargSrt.exp_date AS FirstOfexp_date INTO Temp From TargSrt WHERE TargSrt.opt_symbol = 'L GM'

the above statement simply doesnt insert anything into the TEMP table, whereas the following statement works fine (exactly same except for where clause)

SELECT TargSrt.opt_symbol AS FirstOfopt_symbol, TargSrt.Ticker, TargSrt.imp_volat AS Hvolat, TargSrt.strike AS FirstOfstrike, TargSrt.exp_date AS FirstOfexp_date INTO Temp From TargSrt WHERE TargSrt.opt_symbol = 'ABCD'

How do I structure the where clause to select rows whose data contains spaces
 
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

It just may be that there aren't any data in the source table that
have values with spaces in them. Or, there may be more than one space
in the value, but it appears as if there is only one space. E.g.:
L<space>GM doesn't equal L<space><space>GM, but they can look alike:


L GM L GM

especially in proportional font displays.

MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBQEZQaoechKqOuFEgEQLu4gCgqIWVsCFBdRqp1l+Z1xWmPEPigwUAnRGr
gDoYPus032yV/q3Zrc8II6OP
=d0/h
-----END PGP SIGNATURE-----
 
What happens if you turn this into a plain old SELECT query? Do you see any
rows in Datasheet view? If not, are you certain that you have a row with
opt_symbol = 'L GM'? Is it possible that there's some other unprintable
character between the L and the G - not a space?

--
John Viescas, author
"Microsoft Office Access 2003 Inside Out"
"Running Microsoft Access 2000"
"SQL Queries for Mere Mortals"
http://www.viescas.com/
(Microsoft Access MVP since 1993)
Ken said:
I am trying to execute this INSERT INTO statement, and it fails when I
specify a column that includes a space, such as "L GM", however when the
column data contains no spaces as in "LGM" the query executes fine:
SELECT TargSrt.opt_symbol AS FirstOfopt_symbol, TargSrt.Ticker,
TargSrt.imp_volat AS Hvolat, TargSrt.strike AS FirstOfstrike,
TargSrt.exp_date AS FirstOfexp_date INTO Temp From TargSrt WHERE
TargSrt.opt_symbol = 'L GM';
the above statement simply doesnt insert anything into the TEMP table,
whereas the following statement works fine (exactly same except for where
clause):
SELECT TargSrt.opt_symbol AS FirstOfopt_symbol, TargSrt.Ticker,
TargSrt.imp_volat AS Hvolat, TargSrt.strike AS FirstOfstrike,
TargSrt.exp_date AS FirstOfexp_date INTO Temp From TargSrt WHERE
TargSrt.opt_symbol = 'ABCD';
 
Back
Top