pdate you’re the database created in week5: lab5. Write some MYSQL code to select three different sets of data and display them on the screen. Also, delete two different records from any of the table in your the database and then print the remaining data on the screen. Finally, update one of your table with five more new rows of data and print the result of the table on the screen. /*create database CSC306Class*/ create database CSC3067Class; /*use this database to create tables*/ use CSC3067Class; create table studentInf( studentID int primary key, FirstName varchar(50), LastName varchar(50), Roles varchar(50), DobY varchar(50) ); /*inserting data into studentInf table*/ insert into studentInf values (1,'Josiah','Bartlet','President','1942'); insert into studentInf values (2,'Leo','McGarry','Cheif Of Staff','1948'); insert into studentInf values (3,'Josh','Lyman','Deputy Chief of Staff','1961'); insert into studentInf values (4,'Sam','Seaborn','Deputy Communications Director','1954'); insert into studentInf values (5,'Toby','Ziegler','White House Communications Director','1959'); select * from studentInf; create table IntructorInf( InstID int primary key, InstName varchar(50), Roles varchar(50), DobY varchar(50), Charac varchar(50) ); /*inserting data into IntructorInf table*/ insert into IntructorInf values (101,'Mrs. Landingham','Executive Secretary','1935','n/a'); insert into IntructorInf values (102,'Admiral Percy Fitzwallace',' Chairman of the JSOC','1951','John Amos'); insert into IntructorInf values (103,'Donnatella Moss','Senior Assistance to DCS','1952','Jenna Meloney'); insert into IntructorInf values (104,'Andrea Wyatt','Rep. Maryland Dist','1954','Kathleen York'); insert into IntructorInf values (105,'C.J. Cregg ','White House Press Secretary','1959','Allison Janney'); /*selecting records*/ select * from IntructorInf; create table LikedAndDisliked( LikedAndDislikedID int primary key, studentID int, InstID int, likeorDislike boolean, feedbackDate date, foreign key(studentID) references studentInf(studentID), foreign key(InstID) references IntructorInf(InstID)); /*inserting data into LikedAndDisliked table*/ insert into LikedAndDisliked values (1,1,101,true,'2020/12/11'); insert into LikedAndDisliked values (2,2,102,false,'2020/12/12'); insert into LikedAndDisliked values (3,3,103,true,'2020/12/01'); insert into LikedAndDisliked values (4,4,104,false,'2020/12/25'); insert into LikedAndDisliked values (5,5,105,true,'2020/12/30'); /*selecting records*/ select * from LikedAndDisliked; SELECT * FROM StudentInf; SELECT * FROM IntructorInf; SELECT * FROM LikedAndDisliked; DELETE FROM StudentInf WHERE studentID IN (1,2); INSERT INTO StudentInf VALUES (106, 'Bob', 'Russel', '1948', 'Presidental Candidate'); INSERT INTO StudentInf VALUES (107, 'John', 'Hoynes', '1952', 'Vice President'); INSERT INTO StudentInf VALUES (108, 'Rob', 'Jr', '1969', 'US Reps'); INSERT INTO StudentInf VALUES (109, 'Eric', 'Baker', '1968', 'Governor'); INSERT INTO StudentInf VALUES (110, 'Eirc', 'Crowley', '1965', 'Lawyer'); SELECT * FROM StudentInf;
Please help as i am getting error after deleting student entrety for 2 entry
Update you’re the
/*create database CSC306Class*/
create database CSC3067Class;
/*use this database to create tables*/
use CSC3067Class;
create table studentInf(
studentID int primary key,
FirstName varchar(50),
LastName varchar(50),
Roles varchar(50),
DobY varchar(50)
);
/*inserting data into studentInf table*/
insert into studentInf values (1,'Josiah','Bartlet','President','1942');
insert into studentInf values (2,'Leo','McGarry','Cheif Of Staff','1948');
insert into studentInf values (3,'Josh','Lyman','Deputy Chief of Staff','1961');
insert into studentInf values (4,'Sam','Seaborn','Deputy Communications Director','1954');
insert into studentInf values (5,'Toby','Ziegler','White House Communications Director','1959');
select * from studentInf;
create table IntructorInf(
InstID int primary key,
InstName varchar(50),
Roles varchar(50),
DobY varchar(50),
Charac varchar(50)
);
/*inserting data into IntructorInf table*/
insert into IntructorInf values (101,'Mrs. Landingham','Executive Secretary','1935','n/a');
insert into IntructorInf values (102,'Admiral Percy Fitzwallace',' Chairman of the JSOC','1951','John Amos');
insert into IntructorInf values (103,'Donnatella Moss','Senior Assistance to DCS','1952','Jenna Meloney');
insert into IntructorInf values (104,'Andrea Wyatt','Rep. Maryland Dist','1954','Kathleen York');
insert into IntructorInf values (105,'C.J. Cregg ','White House Press Secretary','1959','Allison Janney');
/*selecting records*/
select * from IntructorInf;
create table LikedAndDisliked(
LikedAndDislikedID int primary key,
studentID int,
InstID int,
likeorDislike boolean,
feedbackDate date,
foreign key(studentID) references studentInf(studentID),
foreign key(InstID) references IntructorInf(InstID));
/*inserting data into LikedAndDisliked table*/
insert into LikedAndDisliked values (1,1,101,true,'2020/12/11');
insert into LikedAndDisliked values (2,2,102,false,'2020/12/12');
insert into LikedAndDisliked values (3,3,103,true,'2020/12/01');
insert into LikedAndDisliked values (4,4,104,false,'2020/12/25');
insert into LikedAndDisliked values (5,5,105,true,'2020/12/30');
/*selecting records*/
select * from LikedAndDisliked;
SELECT * FROM StudentInf;
SELECT * FROM IntructorInf;
SELECT * FROM LikedAndDisliked;
DELETE FROM StudentInf WHERE studentID IN (1,2);
INSERT INTO StudentInf VALUES (106, 'Bob', 'Russel', '1948', 'Presidental Candidate');
INSERT INTO StudentInf VALUES (107, 'John', 'Hoynes', '1952', 'Vice President');
INSERT INTO StudentInf VALUES (108, 'Rob', 'Jr', '1969', 'US Reps');
INSERT INTO StudentInf VALUES (109, 'Eric', 'Baker', '1968', 'Governor');
INSERT INTO StudentInf VALUES (110, 'Eirc', 'Crowley', '1965', 'Lawyer');
SELECT * FROM StudentInf;
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 5 images