Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

mysql

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?

like image 245
JohnRaja Avatar asked Feb 10 '10 08:02

JohnRaja


2 Answers

You'll have to quote the database name:

SELECT * FROM `de mo`.tablename

Spaces in identifiers are best avoided really.

like image 72
martin clayton Avatar answered Oct 05 '22 02:10

martin clayton


use backticks:

`de mo`
like image 42
Tim Avatar answered Oct 05 '22 02:10

Tim