cancel
Showing results for 
Search instead for 
Did you mean: 

Chage to MYSQL Syntax ?

starfry
Rising Star
Posts: 244
Thanks: 1
Fixes: 1
Registered: 14-09-2007

Chage to MYSQL Syntax ?

Hi,

My web site has stopped working.

The cause is that MYSQL syntax seems to have changed. For example the simple SELECT statement:



SELECT * from MYTABLE;

now fails. Instead it is expecting

SELECT * from `MYTABLE`;

Notice the reverse quotes around MYTABLE.

Why is this ? I can't find any reference to these quotes. Help!!! I need to get back on line and I don't want to have to change every SQL statement in my system!!!!!
5 REPLIES
Plusnet Staff
Plusnet Staff
Posts: 12,169
Thanks: 18
Fixes: 1
Registered: 04-04-2007

Chage to MYSQL Syntax ?

Hi,

The MySQL syntax shouldn't have changed, it should still be fine. Unless one of your tables has a reserved name under MySQL 4.1 it should be OK. Can you give me a URL of a page that isn't working?
N/A

Chage to MYSQL Syntax ?

John - whats the real table name (or is it really MYTABLE in which case sorry Wink )
starfry
Rising Star
Posts: 244
Thanks: 1
Fixes: 1
Registered: 14-09-2007

Chage to MYSQL Syntax ?

Hi Dave,

I think the problem is caused by me having a table called DIV. This was not a problem 2 days ago.

I have changed my code to place reverse quotes around DIV and it is now working again (luckily it's coded molularly so I only had to make a cange once).

I presume DIV must be a new reserved word ??

Cheers,
John
N/A

Chage to MYSQL Syntax ?

Yep, from 4.1 DIV is now a reserved word:-

Quote

New Operators

A pair of new operators were added in MySQL 4.1, making the results of integer division available.

dividend DIV divisor

First we have DIV, which operates on two numbers, new in MySQL 4.1.0.

The DIV operator does integer division on its two numeric operands. That is, DIV takes the dividend value, divides it by the divisor, and returns only the integer portion of the result. This contrasts with division done by the / (divide) operator, which returns the full result of such a division.

DIV works correctly with numbers up to the BIGINT range. It returns NULL if either operand is NULL. Oh, and there's one other result of this implementation: DIV is now a reserved keyword in MySQL.

mysql> SELECT 1025 DIV 13;


Taken from MySQL's website... http://mysql.easynet.be/doc/refman/4.1/en/reserved-words.html contains a list of reserved words in 4.1 (towards the bottom of the page).
starfry
Rising Star
Posts: 244
Thanks: 1
Fixes: 1
Registered: 14-09-2007

Chage to MYSQL Syntax ?

Well that's eplained it. Cheers guys!