File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and Relational Databases and the fly likes MySQL code Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "MySQL code" Watch "MySQL code" New topic

MySQL code

Nanuim Ud

Joined: Jun 17, 2013
Posts: 3

Could someone please assist me point out the error in this sql statement below.
I have created a table "sunnettable" and I am trying to create the table "dailyactivity" and link it to the first table

CREATE TABLE `dailyactivity` (
`employee_id` Varchar(10) NOT NULL,
`report_date` date NOT NULL,
`client_details` VARCHAR(255),
`assignment` VARCHAR(255),
`resolutions` VARCHAR(255),
`comments` VARCHAR(255),
PRIMARY KEY (`da_id`))
CONSTRAINT fk_sunnettable FOREIGN KEY (employee_id) REFERENCES sunnettable (employee_id)

This is the error I'm getting:

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 'CONSTRAINT fk_sunnettable FOREIGN KEY (employee_id) REFERENCES sunnettable (empl' at line 10

I'll really appreciate any help!
Ulf Dittmer

Joined: Mar 22, 2005
Posts: 42965
Welcome to JavaRanch. According to, such constraints need to be inside the parentheses.
I agree. Here's the link:
subject: MySQL code
It's not a secret anymore!