I need help writing this program. I already have the database I will be using. T
ID: 3883074 • Letter: I
Question
I need help writing this program. I already have the database I will be using. The name of the database is Flights.
please use SELECT, INSERT, UPDATE, or DELETE statements to identify and correct data issues.
1. Write a script to select all data from the planes table.
2. Update the planes table so that rows that have no year will be assigned the year 2013. (missing values will display as NULL).
3. Insert a new record to the planes table with the following values:
Tailnum: N15501
Year: 2013
type: Fixed wing single engine
Manufacturer: BOEING
Model: A222-101
Engines: 3
Seats: 100
Speed: NULL (notice this is not a text value but truly the absence of any value: "empty". As such, don't use single or double quotes around NULL when inserting this value).
Engine: Turbo-fan
4. Delete the newly inserted record on step 3.
Explanation / Answer
1.Write a script to select all data from the planes table.
Ans- SELECT * FROM planes;
Note: * select all the data from the table either the data in table are 1 or n number of data. if there are no data in the table this will show you the
2. Update the planes table so that rows that have no year will be assigned the year 2013. (missing values will display as NULL).
Ans- UPDATE planes set year='2013' WHERE year is null;
3. Insert a new record to the planes table with the following values:
Ans- INSERT INTO planes(Tailnum,Year,type,manufacturer,Model,Engines,Seats,Speed,Engine)
values('N15501',2013,'Fixed wing single engine','BOEING','A222-101',3,100,NULL,'Turbo-fan');
4. Delete the newly inserted record on step.
If you are using primary key with auto increment it will delete the last record using this sql query
Ans- DELETE FROM Planes where Tailnum in(SELECT max(Tailnum) from planes);
"SELECT max(Tailnum) from planes" this query gives the maximum no of tailnum which was auto increment whenever you are inserted the data to the table and delete the records.