2 The code extract below inserts a record into a table named \"STUDENT. The prim
ID: 3910696 • Letter: 2
Question
2 The code extract below inserts a record into a table named "STUDENT. The primary key is matric" s?php Shostname "localhost Susername "mweb" Spassword "rigbonla Sdatabase student records" Scon - mysql connect (Shostname, Susername, Spassword, Sdatabase): Ssql- "INSERT INTO STUDENT (matric, firstname, surname, email)VALUESC123525663 Adewale Mathew', adewale@yahoo.com mysqliquery(Scon, Ssql); mys?li,close(Scon); 5 i Write an SQL statement to change the surname of the student to "Bello" ii Write an SQL statement to delete the record of the student ii Write an SQL statement to insert the details of another student into the table. Use any value of your choice, iv Write an SQL statement to retrieve the record of the student with matric number 127039451 from the STUDENT table Write an SQl. statement to retrieve the records of all the students vExplanation / Answer
i. UPDATE STUDENT SET surname='Bello';
Update command will update STUDENT table's column surname to Bello. Here we have only one record in the table, so no need of WHERE commnad. if we have more than one record and want to specifiy any particular record to change, then we need to use WHERE clause.
ii. DELETE FROM STUDENT;
Delete will delete the record in the table. Here we have only one record in the table, so no need of WHERE commnad. if we have more than one record and want to specifiy any particular record to delete, then we need to use WHERE clause.
iii. INSERT INTO STUDENT VALUES(123,'Chegg','Expert','Expert@chegg.com');
Another way inserting values into the table. Here we don't mentioned the column names like given question. values will be assigned according to the columns order.
iv. SELECT * FROM STUDENT WHERE matric=127039451;
Select will displays the record values, * will displays all the columns in the record. where clause will specify paticular student based on matric value.
v. SELECT * FROM STUDENT;
select * will displays all the records in the student table, because we dont mentioned any conditon. so it will displays all the records.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.