faqts : Computers : Databases : MySQL : Language and Syntax : Field Types

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

10 of 16 people (63%) answered Yes
Recently 5 of 10 people (50%) answered Yes

Entry

Can a column name contain spaces?
How do I use a column name containing spaces in a query?

Jan 23rd, 2000 19:11
Nathan Wallace, Richard Lynch


Assume you have a table like this:

    FLIGHTS:
        Fields: Airline, Flight Number

So the column "Flight Number" contains spaces.  To reference this column
you need to enclose it in quotes as follows:

    select 'FLIGHTS.Flight Number' ...

I also would stay away from field names with spaces:  Some databases
will give you grief over it, and even if they don't, the small benefit
in readability is out-weighed by the loss when you have to add
apostrophes to delimit the field.