homepage Welcome to WebmasterWorld Guest from 54.145.191.14
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / Code, Content, and Presentation / Databases
Forum Library, Charter, Moderator: open

Databases Forum

    
Alter table - foreign key - Error 1064
kiwibrit

10+ Year Member



 
Msg#: 4371259 posted 9:53 pm on Oct 5, 2011 (gmt 0)

I have two tables within a database.

The first is 'clicks'

It has four fields:
Name: fil_id
type: int(10)
PRIMARY KEY

Name: customer_id
type: int(4)

Name:location
Type: varchar(100)

Name: uniqid
Type: varchar(15)

The second table is 'downloads'

It has two fields:

Name: customer_id
Type: int(4)
PRIMARY KEY

Name: username
Type: varchar(35)

When I run the following SQL in phpmyadmin

ALTER TABLE clicks ADD FOREIGN KEY (customer_id) REFERENCES downloads(customer_id) SHOW ERRORS

I get an error #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 'SHOW ERRORS' at line 1

I've looked at this one quite intensively. As the tables hold no data I could just drop them and recreate, including the foreign key. But I would like to nail the problem and I just can't figure it. Can you help?

I am running MySQL 5.07 locally on my Windows 7 PC.

 

penders

WebmasterWorld Senior Member penders us a WebmasterWorld Top Contributor of All Time 5+ Year Member Top Contributors Of The Month



 
Msg#: 4371259 posted 8:33 am on Oct 6, 2011 (gmt 0)

ALTER TABLE clicks ADD FOREIGN KEY (customer_id) REFERENCES downloads(customer_id) SHOW ERRORS


Have you used SHOW ERRORS before in this context? I thought it was a separate statement?
12.4.5.14. SHOW ERRORS Syntax [dev.mysql.com]

kiwibrit

10+ Year Member



 
Msg#: 4371259 posted 9:49 am on Oct 6, 2011 (gmt 0)

Ha! No I hadn't, thank you. SQL ran correctly once I followed up on your link.

I've forgotten how to mark the thread as solved.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Databases
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved