General SQL Question, Column Headings

M

Matt Purdy

Hello all,
I was wondering when using an sql query how to select from a certain table
and also from a certain column. My dilemma is that the column heading has a
space in it ex: first name
I do not have the rights to change the column heading which would be the
easiest solution so I'm trying to figure it our.
SELECT * FROM Persons WHERE First Name = "Matt"
First Name above is my problem, thanks to all.
 
D

Dirk Goldgar

Matt Purdy said:
Hello all,
I was wondering when using an sql query how to select from a certain
table and also from a certain column. My dilemma is that the column
heading has a space in it ex: first name
I do not have the rights to change the column heading which would be
the easiest solution so I'm trying to figure it our.
SELECT * FROM Persons WHERE First Name = "Matt"
First Name above is my problem, thanks to all.

Use square brackets to enclose the nonstandard field name:

SELECT * FROM Persons WHERE [First Name] = "Matt"

In the long run, it's a good idea to fix all such improper names at the
source, so that this sort of problem doesn't arise.
 
V

Van T. Dinh

Try:

SELECT * FROM Persons WHERE [First Name] = "Matt"

You will need to make sure that you use the square brackets if you can't
change the Field names. I am lazy so I don't use space or special
characters in names in Access.
 
Top