Help plz with sql syntax (1 Viewer)

joet1984

New member
Local time
Yesterday, 18:22
Joined
Dec 12, 2008
Messages
2
I keep getting errors and I don't know what I'm doing wrong. Can anyone help me? I am using mysql workbench and putty.exe. my syntax looks like this

SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0;
SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;
SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='TRADITIONAL';
CREATE SCHEMA IF NOT EXISTS `jptulowiecki_db` DEFAULT CHARACTER SET latin1 COLLATE latin1_swedish_ci ;
USE `jptulowiecki_db`;
-- -----------------------------------------------------
-- Table `jptulowiecki_db`.`Parts`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `jptulowiecki_db`.`Parts` (
`idParts` NOT NULL ,
`Keyboards` VARCHAR(30) NULL ,
`Mouse` VARCHAR(30) NULL ,
`Monitors` VARCHAR(30) NULL ,
`Harddrives` VARCHAR(30) NULL ,
`RAM` VARCHAR(30) NULL ,
PRIMARY KEY (`idParts`) )
ENGINE = InnoDB;

-- -----------------------------------------------------
-- Table `jptulowiecki_db`.`Sales_has_Products`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `jptulowiecki_db`.`Sales_has_Products` (
`Sales_idSales` INT NOT NULL ,
`Products_idProducts` INT NOT NULL ,
`Products_idProducts1` INT NOT NULL ,
PRIMARY KEY (`Sales_idSales`, `Products_idProducts`, `Products_idProducts1`) );

-- -----------------------------------------------------
-- Table `jptulowiecki_db`.`Products`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `jptulowiecki_db`.`Products` (
`idProducts` NOT NULL ,
`Name` VARCHAR(30) NULL ,
`ModelNumber` VARCHAR(10) NULL ,
`Retail/Sale Price` VARCHAR(20) NULL ,
`Parts_idParts` INT NULL ,
`Sales_has_Products_Sales_idSales` INT NOT NULL ,
`Sales_has_Products_Products_idProducts` INT NOT NULL ,
`Sales_has_Products_Products_idProducts1` INT NOT NULL ,
PRIMARY KEY (`idProducts`, `Sales_has_Products_Sales_idSales`, `Sales_has_Products_Products_idProducts`, `Sales_has_Products_Products_idProducts1`) ,
INDEX `fk_Products_Parts` (`Parts_idParts` ASC) ,
INDEX `fk_Products_Sales_has_Products` (`Sales_has_Products_Sales_idSales` ASC, `Sales_has_Products_Products_idProducts` ASC, `Sales_has_Products_Products_idProducts1` ASC) ,
CONSTRAINT `fk_Products_Parts`
FOREIGN KEY (`Parts_idParts` )
REFERENCES `jptulowiecki_db`.`Parts` (`idParts` )
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `fk_Products_Sales_has_Products`
FOREIGN KEY (`Sales_has_Products_Sales_idSales` , `Sales_has_Products_Products_idProducts` , `Sales_has_Products_Products_idProducts1` )
REFERENCES `jptulowiecki_db`.`Sales_has_Products` (`Sales_idSales` , `Products_idProducts` , `Products_idProducts1` )
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB;

-- -----------------------------------------------------
-- Table `jptulowiecki_db`.`SalesPeople`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `jptulowiecki_db`.`SalesPeople` (
`idSalesPeople` INT NOT NULL ,
`FirstName` VARCHAR(15) NOT NULL ,
`LastName` VARCHAR(20) NOT NULL ,
`Address` VARCHAR(45) NOT NULL ,
`Phone` VARCHAR(15) NULL ,
`HourlyRate` VARCHAR(45) NOT NULL ,
`Parts_idParts` INT NOT NULL ,
`Products_idProducts` INT NOT NULL ,
PRIMARY KEY (`idSalesPeople`) ,
INDEX `fk_SalesPeople_Parts` (`Parts_idParts` ASC) ,
INDEX `fk_SalesPeople_Products` (`Products_idProducts` ASC) ,
CONSTRAINT `fk_SalesPeople_Parts`
FOREIGN KEY (`Parts_idParts` )
REFERENCES `jptulowiecki_db`.`Parts` (`idParts` )
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `fk_SalesPeople_Products`
FOREIGN KEY (`Products_idProducts` )
REFERENCES `jptulowiecki_db`.`Products` (`idProducts` )
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB;

-- -----------------------------------------------------
-- Table `jptulowiecki_db`.`Sales`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `jptulowiecki_db`.`Sales` (
`idSales` NOT NULL ,
`Date` DATETIME NULL ,
`Amount` FLOAT NULL ,
`Time` DATETIME NULL ,
`PaymentMethod` VARCHAR(30) NULL ,
`CustomerName` VARCHAR(30) NULL ,
`CustomerAddress` VARCHAR(45) NULL ,
`SalesPeople_idSalesPeople` INT NOT NULL ,
`Parts_idParts` INT NOT NULL ,
`Sales_has_Products_Sales_idSales` INT NOT NULL ,
`Sales_has_Products_Products_idProducts` INT NOT NULL ,
`Sales_has_Products_Products_idProducts1` INT NOT NULL ,
INDEX `fk_Sales_SalesPeople` (`SalesPeople_idSalesPeople` ASC) ,
INDEX `fk_Sales_Parts` (`Parts_idParts` ASC) ,
PRIMARY KEY (`idSales`, `Sales_has_Products_Sales_idSales`, `Sales_has_Products_Products_idProducts`, `Sales_has_Products_Products_idProducts1`) ,
INDEX `fk_Sales_Sales_has_Products` (`Sales_has_Products_Sales_idSales` ASC, `Sales_has_Products_Products_idProducts` ASC, `Sales_has_Products_Products_idProducts1` ASC) ,
CONSTRAINT `fk_Sales_SalesPeople`
FOREIGN KEY (`SalesPeople_idSalesPeople` )
REFERENCES `jptulowiecki_db`.`SalesPeople` (`idSalesPeople` )
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `fk_Sales_Parts`
FOREIGN KEY (`Parts_idParts` )
REFERENCES `jptulowiecki_db`.`Parts` (`idParts` )
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `fk_Sales_Sales_has_Products`
FOREIGN KEY (`Sales_has_Products_Sales_idSales` , `Sales_has_Products_Products_idProducts` , `Sales_has_Products_Products_idProducts1` )
REFERENCES `jptulowiecki_db`.`Sales_has_Products` (`Sales_idSales` , `Products_idProducts` , `Products_idProducts1` )
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB;

SET SQL_MODE=@OLD_SQL_MODE;
SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;
SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;



------------------------------------------------
my errors look like this:
login as: j.p.tulowiecki
j.p.tulowiecki@cs4.sunyocc.edu's password:
Last login: Thu Dec 11 20:20:50 2008 from cpe-67-246-102-19.twcny.res.rr.com
[j.p.tulowiecki@babi ~]$ mysql -u jptulowiecki -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 27877 to server version: 5.0.27-standard
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> use jptulowiecki_db;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> show tables;
+---------------------------+
| Tables_in_jptulowiecki_db |
+---------------------------+
| Sales_has_Products |
+---------------------------+
1 row in set (0.00 sec)
mysql> drop table sales_has_products;
ERROR 1051 (42S02): Unknown table 'sales_has_products'
mysql> drop table 'sales_has_products';
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 ''sales_has_products'' at line 1
mysql> drop table
-> ;
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 1
mysql> exit
Bye
[j.p.tulowiecki@babi ~]$ nano
[j.p.tulowiecki@babi ~]$ mysql -u jptulowiecki -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 27878 to server version: 5.0.27-standard
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> use jptulowiecki_db;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> drop tables;
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 1
mysql> show tables;
+---------------------------+
| Tables_in_jptulowiecki_db |
+---------------------------+
| Sales_has_Products |
+---------------------------+
1 row in set (0.00 sec)
mysql> drop table Sales_has_Products
-> ;
Query OK, 0 rows affected (0.00 sec)
mysql> show tables;
Empty set (0.00 sec)
mysql> source Joseph.sql;
Query OK, 0 rows affected (0.00 sec)
Query OK, 0 rows affected (0.00 sec)
Query OK, 0 rows affected (0.00 sec)
Query OK, 0 rows affected, 1 warning (0.00 sec)
Database changed
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 'jptulowiecki_db`.`Parts` --
NOT EXISTS `jptulowiecki_db`.`Parts` (
`idParts` N' at line 2
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 'jptulowiecki_db`.`Sales_has_Products` --
NOT EXISTS `jptulowiecki_db`.`Sales_has' at line 2
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 'jptulowiecki_db`.`Products` --
NOT EXISTS `jptulowiecki_db`.`Products` (
`idPr' at line 2
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 'jptulowiecki_db`.`SalesPeople` --
NOT EXISTS `jptulowiecki_db`.`SalesPeople` (
' at line 2
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 'jptulowiecki_db`.`Sales` --
NOT EXISTS `jptulowiecki_db`.`Sales` (
`idSales` N' at line 2
Query OK, 0 rows affected (0.00 sec)
Query OK, 0 rows affected (0.00 sec)
Query OK, 0 rows affected (0.00 sec)
mysql> show tables;
Empty set (0.00 sec)
mysql> SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0;
Query OK, 0 rows affected (0.00 sec)
mysql> SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;
Query OK, 0 rows affected (0.00 sec)
mysql> SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='TRADITIONAL';
Query OK, 0 rows affected (0.00 sec)
mysql>
mysql> CREATE SCHEMA IF NOT EXISTS `jptulowiecki_db` DEFAULT CHARACTER SET latin1 COLLATE latin1_swedish_ci ;
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql> USE `jptulowiecki_db`;
Database changed
mysql> CREATE TABLE IF NOT EXISTS `jptulowiecki_db`.`Parts` (
-> `idParts` NOT NULL ,
-> `Keyboards` VARCHAR(30) NULL ,
-> `Mouse` VARCHAR(30) NULL ,
-> `Monitors` VARCHAR(30) NULL ,
-> `Harddrives` VARCHAR(30) NULL ,
-> `RAM` VARCHAR(30) NULL ,
-> PRIMARY KEY (`idParts`) )
-> ENGINE = InnoDB;
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 'NOT NULL ,
`Keyboards` VARCHAR(30) NULL ,
`Mouse` VARCHAR(30) NULL ,
`Moni' at line 2
mysql> SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0;
Query OK, 0 rows affected (0.00 sec)
mysql> SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;
Query OK, 0 rows affected (0.00 sec)
mysql> SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='TRADITIONAL';
Query OK, 0 rows affected (0.00 sec)
mysql>
mysql> CREATE SCHEMA IF NOT EXISTS `jptulowiecki_db` DEFAULT CHARACTER SET latin1 COLLATE latin1_swedish_ci ;
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql> USE `jptulowiecki_db`;
Database changed
mysql>
mysql> -- -----------------------------------------------------
mysql> -- Table `jptulowiecki_db`.`Parts`
mysql> -- -----------------------------------------------------
mysql> CREATE TABLE IF NOT EXISTS `jptulowiecki_db`.`Parts` (
-> `idParts` NOT NULL ,
-> `Keyboards` VARCHAR(30) NULL ,
-> `Mouse` VARCHAR(30) NULL ,
-> `Monitors` VARCHAR(30) NULL ,
-> `Harddrives` VARCHAR(30) NULL ,
-> `RAM` VARCHAR(30) NULL ,
-> PRIMARY KEY (`idParts`) )
-> ENGINE = InnoDB;
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 'NOT NULL ,
`Keyboards` VARCHAR(30) NULL ,
`Mouse` VARCHAR(30) NULL ,
`Moni' at line 2
mysql>
mysql> source Joseph.sql;
Query OK, 0 rows affected (0.00 sec)
Query OK, 0 rows affected (0.00 sec)
Query OK, 0 rows affected (0.00 sec)
Query OK, 0 rows affected, 1 warning (0.00 sec)
Database changed
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 'jptulowiecki_db`.`Parts` --
NOT EXISTS `jptulowiecki_db`.`Parts` (
`idParts` N' at line 2
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 'jptulowiecki_db`.`Sales_has_Products` --
NOT EXISTS `jptulowiecki_db`.`Sales_has' at line 2
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 'jptulowiecki_db`.`Products` --
NOT EXISTS `jptulowiecki_db`.`Products` (
`idPr' at line 2
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 'jptulowiecki_db`.`SalesPeople` --
NOT EXISTS `jptulowiecki_db`.`SalesPeople` (
' at line 2
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 'jptulowiecki_db`.`Sales` --
NOT EXISTS `jptulowiecki_db`.`Sales` (
`idSales` N' at line 2
Query OK, 0 rows affected (0.00 sec)
Query OK, 0 rows affected (0.00 sec)
Query OK, 0 rows affected (0.00 sec)
mysql>

any help i would love you guys. I hope I'm in the right forum here. thanks in advance
 

Users who are viewing this thread

Top Bottom