query to create table

2001-04-13 Thread Venkatesh T

Hi
   Though it is a simple question, i want help reg this.  In the manual
it is giving we can create table with foreign key and references table
to make foreign key concept though it is not supporting the same.  When
i try to create the table with foreign key it is giving

ERROR 1064: You have an error in your SQL syntax near 'order
smallint(2), foreign
key (code) references master(code))' at line 1

My query is:

create table master(code varchar(10) not null, name varchar(20), primary
key (code))

It is creating table correctly

when i try to create this
create table details(code varchar(10),  scode varchar(20), order
smallint(2), foreign key (code) references master(code));

I am getting the above error.  I tried different options.

Can u any of u send me the correct syntax with the example.

My platform is Win NT.

Thanks in advance

Regards
venkatesh




-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




Re: query to create table

2001-04-13 Thread Fred van Engen

Hi,

On Fri, Apr 13, 2001 at 08:39:52PM +0530, Venkatesh T wrote:
 when i try to create this
 create table details(code varchar(10),  scode varchar(20), order
 smallint(2), foreign key (code) references master(code));
 

ORDER is a reserved word in SQL. If you really want, you can use it
for column names by back-quoting it like `order`. You will have to
do that in all your queries then and any middleware you use would
have to do the same. So I suggest you use a different name.

Regards,

Fred.


-- 
Fred van Engen  XO Communications B.V.
email: [EMAIL PROTECTED] Televisieweg 2
tel: +31 36 5462400 1322 AC  Almere
fax: +31 36 5462424 The Netherlands

-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php