Page 1 of 1

Help with a 6 line SQL CODE...

Posted: Sun Oct 31, 2004 10:16 am
by Uri
Hi all!
I'm not a newbie in PHP, altough I'm a newbie here...
I'm 13 years old.
I started learning PHP 6 months ago and now, after reading
1000+ about it and experiencing it I have a bitti problem.

I am familiar with MySQL only that I never experienced writing
on my own SQL code...1
OK enough about me.

Here is my problem:

Code: Select all

CREATE TABLE events_megamot(
eID INT UNSIGNED NOT NULL AUTO_INCREMENT,
event VARCHAR(200) NOT NULL,
by VARCHAR(25) NOT NULL,
date DATE NOT NULL,
PRIMARY KEY (eID)
);
I'm getting an error:

Code: Select all

#1064 - 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 'by VARCHAR(25) NOT NULL,
date DATE NOT NULL,
PRIMARY KEY (eID
My server started using phpMyAdmin 2.6.0 does it has something to do
with it?

Thank you all geniuses!

Uri.

Posted: Sun Oct 31, 2004 10:32 am
by swdev
by is a reserved MySQL word, so you can't use it for the name of a column. Use another name.

http://dev.mysql.com/doc/mysql/en/Reserved_words.html

Posted: Sun Oct 31, 2004 10:34 am
by Uri
Woops!
Found it!
After almost breaking my head I must thank phpMyAdmin for thier colors
in SQL. I saw that the word "by" is in purple as the data type(VARCHAR, DATE, INT ect.).
I didn't know "by" is a datatype - what does it do?

P.S
-----
Thanks swdev didn't saw that.

Posted: Sun Oct 31, 2004 10:47 am
by swdev
by is not a datatype. It is a reserved word. It is used in clauses such as GROUP BY and ORDER BY[/big_search]

Posted: Sun Oct 31, 2004 10:56 am
by Uri
swdev wrote:by is not a datatype. It is a reserved word. It is used in clauses such as GROUP BY and ORDER BY[/big_search]
Oh right!