Alex
Alex

Reputation: 25

SQL: Unsual names

I'm trying to select some information which is inside a table with the name online-players using Left join in SQL however, ever time I run the code it just returns the following error.

"Unknown column 'ontime' in 'field list'"

I am assuming its because of the - in the name of the table that course the error.

Is there anyway of going around it so it still gets the information?

Upvotes: 0

Views: 51

Answers (3)

Strawberry
Strawberry

Reputation: 33935

Backticks are required, that's all.

Upvotes: 1

Tim Lehner
Tim Lehner

Reputation: 15251

You can use backticks (`) to refer to the table.

select * from `online-players`

This is provided that you don't have a typo in your query and such.

Upvotes: -1

Hanky Panky
Hanky Panky

Reputation: 46900

That's not true, that error will be generated only when the corresponding field name doesn't exist. However you can enclose field and table names with backticks to be sure

Upvotes: 1

Related Questions