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.

Question
Asked Dec 1, 2019

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.

check_circle

Expert Answer

Step 1

Creating Table and Inserting then values into it-

The Create Table statement is used to create a table in SQL.

Syntax for Creating Table-

 Create Table table_name

(

column1 data_type(size),

column2 data_type(size),

column3 data_type(size),

....

);

The sql query is given below-

/*Create a table named Book*/

create table Book(id integer PRIMARY KEY, Book_title varchar(100),Book_author varchar(100));

Syntax for inserting the values-

insert into table_name (column1, column2, column3,..) values ( value1, value2, value3,..);

/*Inserting the values*/

insert into Book(id, Book_title,Book_author) values(1, "Concept of Physics","HC Verma");

insert into Book(id, Book_title,Book_author) values(2, "Fundamentals of Algebra","Shiv Shukla");

insert into Book(id, Book_title,Book_author) values(3, "Industrial Management","SK Sharma");

Syntax for displaying all the records of the table-

SELECT column1,column2 FROM table_name;

To retrieve all the column from the table-

SELECT * FROM table_name;

Displaying the records from the table-

SELECT id, Book_title, Book_author FROM Book;

Table is shown below-

id
Book title
Book author
Concept of Physics
HC Verma
1
Funadamentals of Algebra
2
Shiv Shukla
Industrial Management
3
SK Sharma
help_outline

Image Transcriptionclose

id Book title Book author Concept of Physics HC Verma 1 Funadamentals of Algebra 2 Shiv Shukla Industrial Management 3 SK Sharma

fullscreen
Step 2

Deleting the data from the table-

DELETE FROM Book WHERE id IN (1,2);

After deleting, displaying the remaining data of the tab...

Book title
Book author
id
Industrial Management
SK Sharma
help_outline

Image Transcriptionclose

Book title Book author id Industrial Management SK Sharma

fullscreen

Want to see the full answer?

See Solution

Check out a sample Q&A here.

Want to see this answer and more?

Solutions are written by subject experts who are available 24/7. Questions are typically answered within 1 hour.*

See Solution
*Response times may vary by subject and question.
Tagged in

Engineering

Computer Science

Databases

Related Computer Science Q&A

Find answers to questions asked by student like you

Show more Q&A add
question_answer

Q: Write a program that simulates a Magic 8-Ball. Prompt the user for a question, and randomly select a...

A: Make program and response.txt file in same directory (folder).do while loop is used to continue to p...

question_answer

Q: Find the employment age of each employee?

A: The SQL statement is given below to construct an EMP table and to add the values according to the gi...

question_answer

Q: List the name of each department, and its total number of employees, and the total amount of salarie...

A:  Query:select dept.deptno, dname, sum(sal), count(empno) from emp  right outer join  dept on emp.dep...

question_answer

Q: How are authentication and authorization alike and how are they different. What is the relationship,...

A: Authentication is a process of proving that someone is who they are claiming to be. It lets a user r...

question_answer

Q: Copy and paste the following definition of the class Car in the submission box and then add a method...

A: Program implementation-def is used to declare a method. Here, def is used to declare brake method in...

question_answer

Q: 4. Explain the steps of the fetch-decode-execute cycle. Your explanation should include what is happ...

A: Fetch-decode-execute cycle stepsFetch-decode-execute cycle is a standard process that describes the ...

question_answer

Q: Define Polymorphism?

A: Polymorphism:A message tells the object to perform a certain method.The same message can produce dif...

question_answer

Q: x = 2, y =1, z =3, what is the value of x, y, z after executing the following codes? switch(x) { cas...

A: Code (in java)-class Main{public static void main (String [] args){int x = 2, y =1, z =3;//initializ...

question_answer

Q: Provide six reasons why computer incidents are so prevalent.

A: Six reasons for computer incidents being prevalentIncreasing complexity increases vulnerability – Th...