473,386 Members | 1,720 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

syntax error that i do not understand

hello, would the experts please help.

this script works with no errors:

-------------------------------
drop table if exists degree;
create table degree (id int unsigned not null auto_increment, primary key
(id)) type=MyISAM;

drop table if exists t;
create table t (id int unsigned not null, foreign key (id) references
degree(id)) type=MyISAM;
-------------------------------

but this one gives the error below:
-------------------------------
drop table if exists degrees;
create table degrees (id int unsigned not null auto_increment, primary key
(id)) type=MyISAM;

drop table if exists t;
create table t (id int unsigned not null, foreign key (id) references
degrees(id)) type=MyISAM;
-------------------------------

the output:

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 'degrees(id)) type=MyISAM' at line 1

i do not see what is so special about the name 'degrees' versus 'degree'. i
am confused. note that changing the erroneous line to the one below works.

create table t (id int unsigned not null, foreign key (id) references
degrees) type=MyISAM;

thanks for any help
konstantin
Jul 20 '05 #1
2 1871
> drop table if exists t;
create table t (id int unsigned not null, foreign key (id) references
degrees(id)) type=MyISAM;


I don't know exactly what the rule it's violating, but when I tried it
in my test database I discovered that it can be made to work in two cases:

create table t (id int unsigned not null, foreign key (id) references
degrees (id));

Notice the space.

create table t (id int unsigned not null, foreign key (id) references
`degrees`(id));

Regards,
Bill K.
Jul 20 '05 #2
thank you for your response. i just discovered that degrees() is a built in
function. it looks like putting a space in between the table name and the
key name works just by chance. because i think a space like that is allowed
in function invocations. so the best way that i see to go around this is to
use quotes.

konstantin
"Bill Karwin" <bi**@karwin.com> wrote in message
news:co*********@enews3.newsguy.com...
drop table if exists t;
create table t (id int unsigned not null, foreign key (id) references
degrees(id)) type=MyISAM;


I don't know exactly what the rule it's violating, but when I tried it in
my test database I discovered that it can be made to work in two cases:

create table t (id int unsigned not null, foreign key (id) references
degrees (id));

Notice the space.

create table t (id int unsigned not null, foreign key (id) references
`degrees`(id));

Regards,
Bill K.

Jul 20 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

699
by: mike420 | last post by:
I think everyone who used Python will agree that its syntax is the best thing going for it. It is very readable and easy for everyone to learn. But, Python does not a have very good macro...
29
by: shank | last post by:
1) I'm getting this error: Syntax error (missing operator) in query expression on the below statement. Can I get some advice. 2) I searched ASPFAQ and came up blank. Where can find the "rules"...
6
by: Euripides J. Sellountos | last post by:
Hello kind people. I hope you can you help me with the following problem. The following snippet fails to compile with g++. (It compiles fine with other compilers.) All I want to do is to throw...
4
by: nonzero | last post by:
I was hoping someone could explain the Syntax of the second argument of the bind() function. bind(sockfd, (struct sockaddr *)&my_addr, sizeof(struct sockaddr)); .....................(struct...
3
by: Manuel | last post by:
I'm trying to compile glut 3.7.6 (dowbloaded from official site)using devc++. So I've imported the glut32.dsp into devc++, included manually some headers, and start to compile. It return a very...
21
by: Dmitry Anikin | last post by:
I mean, it's very convenient when default parameters can be in any position, like def a_func(x = 2, y = 1, z): ... (that defaults must go last is really a C++ quirk which is needed for overload...
7
by: Ray Dillinger | last post by:
Hi. I'm having a problem and I really want to understand it. Here's the situation: I have an array of pointers, and each pointer is the head of a linked list of structs. The structs are...
6
by: Nathan Pinno | last post by:
Why does my compiler say invalid syntax and then highlight the quotation marks in the following code: # This program is to find primes. primes = import math import gmpy while 1: run =...
0
by: Stef Mientki | last post by:
hello, I've syntax error which I totally don't understand: ########## mainfile : import test_upframe2 if __name__ == '__main__': var1 = 33 code = 'print var1 + 3 \n'
0
by: Stef Mientki | last post by:
Terry Reedy wrote: sorry, don't know how this happened, as I always copy/paste ? AFAIK locals() == sys._getframe(0).f_locals AFAIK, again one level up weird, I use it in 2.5 and if I remember...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.