JohnRaja
JohnRaja

Reputation: 2357

How do I run a query on a database whose name contains a space?

In MySQL I created a database with name like de mo, and it contains a table like tablename. When I try to execute a query, for example:

select * from de mo.tablename

I am not able to execute that query. How can I do that?

Upvotes: 5

Views: 587

Answers (3)

Tim
Tim

Reputation: 9489

use backticks:

`de mo`

Upvotes: 3

wallyk
wallyk

Reputation: 57774

It is necessary to quote the name. Usually backticks are used:

select * from `de mo`.tablename

Upvotes: 0

martin clayton
martin clayton

Reputation: 78105

You'll have to quote the database name:

SELECT * FROM `de mo`.tablename

Spaces in identifiers are best avoided really.

Upvotes: 6

Related Questions