我正在创建一个数据库,使用MYSQL并插入数据但是当我尝试删除一行时我没有运气可以有人请帮助我理解为什么行不能删除?我已经为创建的表提供了insert语句和我使用的delete语句,请记住表格显示为已满。
CREATE TABLE IF NOT EXISTS `new_schema2`.`Employee` (
`EID` INT NOT NULL,
`Fname` VARCHAR(45) NOT NULL,
`Lname` VARCHAR(45) NOT NULL,
`AddressID` INT NOT NULL,
`PayLevel` Decimal NOT NULL,
`Jobtitle` VARCHAR(45) NOT NULL,
`DateofEmployment` DATE NOT NULL,
PRIMARY KEY (`EID`))
ENGINE = InnoDB;
#Inserts begin Here
INSERT INTO new_schema2.Employee
(EID, Fname, Lname, AddressID, PayLevel, Jobtitle, DateofEmployment)
VALUES
( 0,'Andrew','Wiggins','7', 10000.00,'Stock Boy','08/11/12' );
INSERT INTO new_schema2.Employee
(EID, Fname, Lname, AddressID, PayLevel, Jobtitle, DateofEmployment)
VALUES
(1,'Andrew','Wiggins','7', 10000.00,'Stock Boy','08/11/12' );
INSERT INTO new_schema2.Employee
(EID, Fname, Lname, AddressID, PayLevel, Jobtitle, DateofEmployment)
VALUES
('2','Nick','Smith','8', 20000.00,'Cashier','08/10/09' );
INSERT INTO new_schema2.Employee
(EID, Fname, Lname, AddressID, PayLevel, Jobtitle, DateofEmployment)
VALUES
('3','Niko','Jackson','9',40000.00,'Manager','05/10/06' );
INSERT INTO new_schema2.Employee
(EID, Fname, Lname, AddressID, PayLevel, Jobtitle, DateofEmployment)
VALUES
('4','Dante','Henderson','10', 20000.00,'Cashier','06/15/09' );
INSERT INTO new_schema2.Employee
(EID, Fname, Lname, AddressID, PayLevel, Jobtitle, DateofEmployment)
VALUES
('5','Jessica','Smith','8',22000.00,'Performer','08/09/11' );
INSERT INTO new_schema2.Employee
(EID, Fname, Lname, AddressID, PayLevel, Jobtitle, DateofEmployment)
VALUES
('6','Alex','Grossi','15',100000.00,'Owner','08/11/02' );
#Delete statements begin here
DELETE FROM new_schema2.employee
WHERE EID = 0 AND Fname='Andrew' AND Lname='Wiggins' AND AddressID='7' AND DateofEmployment='11/12/08' AND PayLevel='10000.00'AND Jobtitle = 'Stock Boy';
答案 0 :(得分:1)
您无需在删除
中指定所有列仅使用此
DELETE FROM new_schema2.employee
WHERE EID = 0
答案 1 :(得分:0)
由于日期条件失败而未删除的原因。
你有字段
`DateofEmployment` DATE NOT NULL
在MySQL中插入08/11/12
时,它将变为2008-11-12
所以delete命令应该是
DELETE FROM Employee
WHERE EID = 0
AND Fname='Andrew'
AND Lname='Wiggins'
AND AddressID='7'
AND DateofEmployment='2008-11-12'
AND PayLevel='10000.00'
AND Jobtitle = 'Stock Boy';
检查
SELECT DateofEmployment FROM Employee
看看数据是如何显示的,你将自己得到答案。