Welcome to WebmasterWorld Guest from 54.196.2.131

Forum Moderators: open

Message Too Old, No Replies

Alter table - foreign key - Error 1064

     
9:53 pm on Oct 5, 2011 (gmt 0)

Full Member

10+ Year Member

joined:Oct 14, 2004
posts: 319
votes: 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.
8:33 am on Oct 6, 2011 (gmt 0)

Senior Member

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

joined:July 3, 2006
posts: 3123
votes: 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]
9:49 am on Oct 6, 2011 (gmt 0)

Full Member

10+ Year Member

joined:Oct 14, 2004
posts: 319
votes: 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.
 

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members