Page 1 of 1

When I add ORDER BY, it gives me an error.

Posted: Sun May 08, 2005 6:28 pm
by Skara
All it says is a syntax error.

Code: Select all

SELECT * FROM books_list WHERE author='{$_GETї'author']}' ORDER BY order
Don't get it, as I have basically the same thing in another one and it works fine:

Code: Select all

SELECT * FROM books_authors ORDER BY name
I know it's something stupid. :P What am I doing wrong?

Posted: Sun May 08, 2005 9:55 pm
by protokol
Show us the entire line of PHP code. Then we can help you.

Posted: Mon May 09, 2005 3:06 am
by Wayne
I think you will find that order is a reserved word.

Posted: Mon May 09, 2005 3:48 am
by JayBird
As wayne says, order is a reserved word

You should change the name of your "order" column to "order_number" or something

Posted: Mon May 09, 2005 8:00 am
by andre_c
... or wrap it in backticks:

Code: Select all

... ORDER BY `order`

Posted: Mon May 09, 2005 5:31 pm
by Skara
aHAH!! Well, didn't even think about that for some reason! ^^; Probably because I'm so bashed from finals week. :P