Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

FROM clause in SQL not working

Status
Not open for further replies.

mraetrudeaujr

Technical User
Dec 20, 2004
137
US
I am trying to adapt a previous SQL statement to work in another database by substituting the appropriate fields, but I keep getting an error stating that my FROM clause syntax is incorrect. I think that it is because I have spaces in the table name, but I cannot figure out how to fix it. Here it is;

Code:
SELECT [STATION], Sum([OLD_1326_VIOLENT_FELON]) AS [OLD 1326 VIOLENT FELON], Sum([OLD_1326_REPEAT_FELON]) AS [OLD 1326 REPEAT FELON], Sum([OLD_1326_TRIPLE_FELON]) AS [OLD 1326 TRIPLE FELON], Sum([OLD_1326_SUPERVISED_RELEASE]) AS [OLD 1326 SUPERVISED RELEASE], Sum([MEETS_OLD_CASID]) AS [OLD CASID]
FROM tbl_CRIMINAL CASE TRACKING
WHERE STATION Is Not Null
GROUP BY [STATION] 
UNION ALL
SELECT "Total", Sum([OLD_1326_VIOLENT_FELON]), Sum([OLD_1326_REPEAT_FELON]), Sum([OLD_1326_TRIPLE_FELON]), Sum([OLD_SUPERVISED_RELEASE]), Sum([MEETS_OLD_CASID])
FROM tbl_CRIMINAL CASE TRACKING
WHERE STATION Is Not Null

I really don't want to change the table name because it will screw up the database, so there has to be a way to show SQL how to accept this table name "tbl_CRIMINAL CASE TRACKING".

PHV was a great help before, so I'm sure that he will recognize this SQL statement. Thanks in advance.
 
When a table or field name contains spaces you need to enclose it in square brackets

FROM [tbl_CRIMINAL CASE TRACKING]
 
I was trying that, but then the "Enter Parameter Value" pop-up box kept coming up. Fortunately, your reaffirmation to use the brackets made me dig deeper into what I had typed for the SQL statement; since I knew that you (we) were right in using these brackets.

Now I discovered my error --- I mistyped the 'OLD_SUPERVISED_RELEASE'. It should have been 'OLD_1326_SUPERVISED_RELEASE'. Alls well now! Thanks.

Al
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top