SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Wizard DoubleDee's Avatar
    Join Date
    Aug 2010
    Location
    Arizona
    Posts
    3,764
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)

    Hyphen in Table Name?

    Can I use a hyphen in a Table name in MySQL? (e.g. "sub-section" or "sub-section_article")

    Or will that break something down the road?


    Debbie

  2. #2
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,247
    Mentioned
    59 Post(s)
    Tagged
    3 Thread(s)
    yes, you can... but it needs to be properly quoted
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  3. #3
    SitePoint Wizard DoubleDee's Avatar
    Join Date
    Aug 2010
    Location
    Arizona
    Posts
    3,764
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by r937 View Post
    yes, you can... but it needs to be properly quoted
    Good thing I asked!

    So what does that mean in practical terms?

    My guess is that I would have to look for any places in my PHP code that has SQL statements, and make sure that those SQL statements use the backtick (`) character around the table name like this...

    Code:
    SELECT *
    FROM `sub-section`
    WHERE blah blah...
    Sound right?

    Thanks,


    Debbie

  4. #4
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,247
    Mentioned
    59 Post(s)
    Tagged
    3 Thread(s)
    Quote Originally Posted by DoubleDee View Post
    Sound right?
    only if you're a masochist

    ask yourself why you really want to do that, when a table name like subsection does not require any special treatment
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  5. #5
    SitePoint Wizard DoubleDee's Avatar
    Join Date
    Aug 2010
    Location
    Arizona
    Posts
    3,764
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by r937 View Post
    only if you're a masochist

    ask yourself why you really want to do that, when a table name like subsection does not require any special treatment
    1.) I am a masochist.

    2.) I *LIKE* hyphens because that make phrases and compound-words easier-to-read, including table-names.

    3.) But in this case, I came to the same conclusion as you, before you responded.

    "subsection" it shall be!


    Off Topic:

    Sometimes I actually do "bend" in the wind...


    Thanks!!


    Debbie


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
  •