Solved

My SQL Database creation error

Posted on 2013-01-13
1
244 Views
Last Modified: 2013-01-14
I am learning to write sql scripts and I am getting the following error and I am not sure why?

      ERROR 1064 (42000): You have an error in your SQL syntax;

  The script (attached is very simple).  I ran a similar script from my text and had no issues.  But when I tried to edit the script for my purposes I keep getting this error.  My script and a screen shot of the error are attached.
Bookmark.sql
Database-Creation-Error.docx
0
Comment
Question by:Genus1
1 Comment
 
LVL 24

Accepted Solution

by:
johanntagle earned 500 total points
ID: 38772922
You need to remove the final comma before the closing parenthesis in the table creation statements.  They should be:

CREATE TABLE Users
(
   UserID int NOT NULL AUTO_INCREMENT PRIMARY KEY,
   Firstname varchar(20) NOT NULL,
   Lastname varchar(20) NOT NULL,
   EmailAddress varchar(20) NOT NULL,
   Username varchar(20) NOT NULL,
   Password varchar(20) NOT NULL
);

CREATE TABLE Urls
(
   UserID int NOT NULL,
   URL varchar(45) NOT NULL,
   FOREIGN KEY (UserID) REFERENCES Users(UserID)
);  

Open in new window

0

Featured Post

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This guide whil teach how to setup live replication (database mirroring) on 2 servers for backup or other purposes. In our example situation we have this network schema (see atachment). We need to replicate EVERY executed SQL query on server 1 to…
I have been using r1soft Continuous Data Protection (http://www.r1soft.com/linux-cdp/) for many years now with the mySQL Addon and wanted to share a trick I have used several times. For those of us that don't have the luxury of using all transact…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question