SQL Query problem: parentheses inside column name

F

Francesco M.

Hi everyone,

I've got a problem with an SQL query.
The column name I'm asking for has parentheses inside its name. [Phone
(off)].
The query is:

select [Phone (off)] from [Providers]

It shows an error about aggregate funzctions.
Pratically I think it needs some GROUP BY because it thinks that
parentheses are like sum() or avg().
Anyone could help me please?

Thank you very much.

Francesco
 
J

John Spencer

That query should work. I tested a query with that exact statement and
it ran for me (Access 2003).

'====================================================
John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
'====================================================
 
F

Francesco M.

I agree completely with you, but the database I'm reading has not been
made by me. ;-)

You should never use special characters or spaces in field or table names..
Now you know why.  I don't think there is any way around it.

--
--Roger Carlson
  MS Access MVP
  Access Database Samples:www.rogersaccesslibrary.com
  Want answers to your Access questions in your Email?
  Free subscription:
 http://peach.ease.lsoft.com/scripts/wa.exe?SUBED1=ACCESS-L


Hi everyone,
I've got a problem with an SQL query.
The column name I'm asking for has parentheses inside its name. [Phone
(off)].
The query is:
select [Phone (off)] from [Providers]
It shows an error about aggregate funzctions.
Pratically I think it needs some GROUP BY because it thinks that
parentheses are like sum() or avg().
Anyone could help me please?
Thank you very much.
Francesco
 
F

Francesco M.

That query should work.  I tested a query with that exact statement and
it ran for me (Access 2003).

'====================================================
  John Spencer
  Access MVP 2002-2005, 2007
  Center for Health Program Development and Management
  University of Maryland Baltimore County
'====================================================
Hi everyone,
I've got a problem with an SQL query.
The column name I'm asking for has parentheses inside its name. [Phone
(off)].
The query is:
select [Phone (off)] from [Providers]
It shows an error about aggregate funzctions.
Pratically I think it needs some GROUP BY because it thinks that
parentheses are like sum() or avg().
Anyone could help me please?
Thank you very much.
Francesco
 
F

Francesco M.

I tried it in Access and it works for me too.
The problem appears when I execute the SQL query using JDBC.
I don't know why, but using JDBC it comes out with the previous
problem.

That query should work.  I tested a query with that exact statement and
it ran for me (Access 2003).

'====================================================
  John Spencer
  Access MVP 2002-2005, 2007
  Center for Health Program Development and Management
  University of Maryland Baltimore County
'====================================================
Hi everyone,
I've got a problem with an SQL query.
The column name I'm asking for has parentheses inside its name. [Phone
(off)].
The query is:
select [Phone (off)] from [Providers]
It shows an error about aggregate funzctions.
Pratically I think it needs some GROUP BY because it thinks that
parentheses are like sum() or avg().
Anyone could help me please?
Thank you very much.
Francesco
 
J

John Spencer

I don't know anything about JDBC, but you can try adding quote marks
around the field name
"Phone (off)"
T-SQL (MS SQL Server) will allow you to specify field and table names
that "break" the naming rules that way. T-SQL does use apostrophes for
delimiting text string.

Good Luck.

Oh, by the way - it would have helped if you had told us that you were
using JDBC to do this in the beginning. At this point, if you have not
solved the problem, you might repost the question with the additional
information that you are using JDBC or you might look for a newsgroup
that specifically treats working with JDBC.

'====================================================
John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
'====================================================

I tried it in Access and it works for me too.
The problem appears when I execute the SQL query using JDBC.
I don't know why, but using JDBC it comes out with the previous
problem.

That query should work. I tested a query with that exact statement and
it ran for me (Access 2003).

'====================================================
John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
'====================================================
Hi everyone,
I've got a problem with an SQL query.
The column name I'm asking for has parentheses inside its name. [Phone
(off)].
The query is:
select [Phone (off)] from [Providers]
It shows an error about aggregate funzctions.
Pratically I think it needs some GROUP BY because it thinks that
parentheses are like sum() or avg().
Anyone could help me please?
Thank you very much.
Francesco
 

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