SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Zealot
    Join Date
    Jul 2002
    Posts
    144
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Does MySQL support tablename.[some column]

    I have read up on the MySQL manual and looked over sitepoint posts. In the manual, it didnt really say anything about column headings with spaces (didnt really find my answer in sitepoint either).

    For example, I had:
    tablename.[Street Address]
    Because of the space in between Street and Address, I needed to put [ ] in my sql statement.

    Now that I am programming with PHP and MySQL, I was wondering if I can do the same thing. I am getting errors once it reaches that part of the statement (the column names with spaces in between them). Is there something I can do instead of renaming my columns?

    Spaz
    Just a little boy trying to make his way into the world...
    ~~~Spaz Boy
    Programmer + Gamer = ProGamer

  2. #2
    Mlle. Ledoyen silver trophy seanf's Avatar
    Join Date
    Jan 2001
    Location
    UK
    Posts
    7,168
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Put backticks (`s) around the column name:

    Code:
    SELECT what FROM table WHERE `column name` = 'sean'
    Sean
    Harry Potter

    -- You lived inside my world so softly
    -- Protected only by the kindness of your nature

  3. #3
    SitePoint Zealot
    Join Date
    Jul 2002
    Posts
    144
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks seanf!

    I must admit, I cant believe I didnt find that in the MySQL manual. Where did you find this information? This will prevent me from asking stupid questions that I can answer myself.
    maybe I missed it or something...

    Thanks,

    Spaz
    Just a little boy trying to make his way into the world...
    ~~~Spaz Boy
    Programmer + Gamer = ProGamer

  4. #4
    Mlle. Ledoyen silver trophy seanf's Avatar
    Join Date
    Jan 2001
    Location
    UK
    Posts
    7,168
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I picked it up somewhere, probably from Matt!

    Sean
    Harry Potter

    -- You lived inside my world so softly
    -- Protected only by the kindness of your nature


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •