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

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…


SELECT *
FROM `sub-section`
WHERE blah blah...

Sound right?

Thanks,

Debbie

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… :lol:

Thanks!!

Debbie