Friday, 26 August 2016

sql - mySQL scripts syntax error



I am getting a syntax error while trying to run this script on mySQL and can't figure out what it wrong. Any help would be appreciated.
Here is the code:



SHOW DATABASES;

DROP DATABASE IF EXISTS conman;

Create Database conman;

USE conman;

CREATE TABLE contact_info(

firstname varchar(25),
middleinitial char(1),
lastname varchar(25),
suffix_description varchar(5),
title_description varchar(5),
jobtitle varchar(40),
department varchar(30),
email varchar(35),
url varchar(50),
IMaddress varchar(25),
phone_number varchar(25),
phonetype_description varchar(10),
birthday date,
notes varchar(255),
companyname varchar(30),
addressLine1 varchar(40),
addressLine2 varchar(45),
city varchar(25),
state_province varchar(20),
zip_postalcode varchar(10),
country_region varchar(15),
companyURL varchar(45),
companyPhone varchar(12),
);

INSERT INTO contact_info
(
firstName,
middleInitial,
lastName,
suffixDescription,
titleDescription,
jobTitle,
department,
email,
url,
IMaddress,
phoneNumber,
phoneDescription,
birthday,
notes,
companyName,
addressLine1,
addressLine2,
city,
state_province,
zip_postalcode,
country_region,
companyURL,
companyPhone,
)
VALUES
(
'Jacob',
'P',
'Jacobson',
'Jr',
'Mr',
'Director',
'Finance',
'rjameson@concor.com',
'www.concor.com/~rjames',
'jpjacobson',
'323-546-6834',
'work',
'1969-07-13',
'All meetings must be scheduled through Charlene Renolds',
'Concor International, Inc.',
'143 South Main Street',
'',
'Los Angeles',
'CA',
'90012-3712',
'USA',
'www.concor.com',
'323-546-6834',
)


And here are the error messages:




ERROR 1064 (42000): 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 ')' at line 26



ERROR 1064 (42000): 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 ')
VALUES
(
'Jacob',
'P',
'Jacobson',
'Jr',
'Mr',
'Director',
'Finance',
'rjameso' at line 26



Answer



Remove the last comma for each one of your CREATE TABLE, INSERT INTO and VALUES statements :



SHOW DATABASES;

DROP DATABASE IF EXISTS conman;

Create Database conman;

USE conman;

CREATE TABLE contact_info(

firstname varchar(25),
middleinitial char(1),
lastname varchar(25),
suffix_description varchar(5),
title_description varchar(5),
jobtitle varchar(40),
department varchar(30),
email varchar(35),
url varchar(50),
IMaddress varchar(25),
phone_number varchar(25),
phonetype_description varchar(10),
birthday date,
notes varchar(255),
companyname varchar(30),
addressLine1 varchar(40),
addressLine2 varchar(45),
city varchar(25),
state_province varchar(20),
zip_postalcode varchar(10),
country_region varchar(15),
companyURL varchar(45),
companyPhone varchar(12)
);

INSERT INTO contact_info
(
firstName,
middleInitial,
lastName,
suffixDescription,
titleDescription,
jobTitle,
department,
email,
url,
IMaddress,
phoneNumber,
phoneDescription,
birthday,
notes,
companyName,
addressLine1,
addressLine2,
city,
state_province,
zip_postalcode,
country_region,
companyURL,
companyPhone
)
VALUES
(
'Jacob',
'P',
'Jacobson',
'Jr',
'Mr',
'Director',
'Finance',
'rjameson@concor.com',
'www.concor.com/~rjames',
'jpjacobson',
'323-546-6834',
'work',
'1969-07-13',
'All meetings must be scheduled through Charlene Renolds',
'Concor International, Inc.',
'143 South Main Street',
'',
'Los Angeles',
'CA',
'90012-3712',
'USA',
'www.concor.com',
'323-546-6834'
)

No comments:

Post a Comment

c++ - Does curly brackets matter for empty constructor?

Those brackets declare an empty, inline constructor. In that case, with them, the constructor does exist, it merely does nothing more than t...