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

K

Ken

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 columns whose data contains spaces?
 
K

Kelvin

Your statement is correct. Are you sure there is data that matches this
criteria? There might be stray spaces that is causing it to not match.

Kelvin

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';
How do I structure the where clause to select columns whose data contains
spaces?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top