You are not logged in.

#1 2010-10-16 10:17:18

Krause
Member
Registered: 2010-01-20
Posts: 81

mySQL will only let me use backticks (not single or double quotes)

What the hell is going on here? This worked fine until a recent update.

SELECT * FROM "table";
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '"table"' at line 1

 SELECT * FROM 'table';
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''table'' at line 1

SELECT * FROM `table`;
(table prints normally here)

12 rows in set (0.00 sec)

The error happens both in the mysql client, phpmyadmin, and all my php scripts. How do I make it accept single and double quotes?

Phpmyadmin has this to say about the mySQL installation

Server: Localhost via UNIX socket
Server version: 5.1.50
Protocol version: 10
User: root@localhost
MySQL charset:                    UTF-8 Unicode            (utf8)

Last edited by Krause (2010-10-16 10:18:16)

Offline

#2 2010-10-16 11:23:24

xvello
Member
Registered: 2010-05-15
Posts: 81
Website

Re: mySQL will only let me use backticks (not single or double quotes)

Hello

In the SQL Standard, table and column names don't have to be between quotes, only values can be (for instance if you have spaces in a value).
Just call "SELECT * FROM table;", that's all.

Offline

#3 2010-10-16 14:00:21

Krause
Member
Registered: 2010-01-20
Posts: 81

Re: mySQL will only let me use backticks (not single or double quotes)

But what if the table name has a space in it?

Offline

#4 2010-10-16 17:27:57

jt512
Member
Registered: 2009-02-19
Posts: 262

Re: mySQL will only let me use backticks (not single or double quotes)

Krause wrote:

But what if the table name has a space in it?

Use backticks?

Jay

Offline

#5 2010-10-18 21:36:05

Carlwill
Member
From: Orlando, FL
Registered: 2008-10-06
Posts: 560
Website

Re: mySQL will only let me use backticks (not single or double quotes)

MySQL is notorious for not following SQL standards. Single quotes are only acceptable and if you have spaces, use back tics.


./

Offline

Board footer

Powered by FluxBB