var sidebar_align = 'right';
var content_container_margin = parseInt('290px');
var sidebar_width = parseInt('270px');
Unanswered: I Cant select column names with Spaces
I'm just a frustrated noob trying to get past my first DB Program. My goal is to get relational data from different tables all ordered by a certain field
Ive noticed early on that i cannot select a column when its name has a space
I have to type:
sql = "SELECT [Chart Number] FROM Table1"
If I write:
sql = "SELECT Chart Number FROM Table1"
I get an error:
"... Cant find Column Name Chart..."
Now the statement i want to use is
sql = "SELECT [PT.Chart Number],[PT.Last Name],[CA.Case Number] FROM Table1 AS PT INNER JOIN Table2 AS CA ON PT.Chart Number = CA.Chart Number ORDER BY PT.Chart Number"
When i Debug i get the same type of error ("... Can't find column name PT.Chart... ")
I'm new to sql so i dont know if my syntax is off. Can someone please help
Ive tried with brackets, without brackets. With and without "AS"
yes, it is
Originally Posted by JuicyMike
put the brackets around the column name only, not both table and column name
SELECT PT.[Chart Number]
, PT.[Last Name]
, CA.[Case Number]
FROM Table1 AS PT
JOIN Table2 AS CA
ON CA.[Chart Number] = PT.[Chart Number]
BY PT.[Chart Number]
Also, don't use spaces in column names. Partly for this reason.
Thanks a lot for the replies, i knew it had to do with the syntax.
Unfortunately the database belongs to another program i just want to connect to it to extract data
Tags for this Thread