Queries in Database
Queries in Database
In order to describe the data structure and to modify the data in the database, queries are used
as instructions. A query enables the joining and filtering of data from various tables.
● Create.
● Alternate.
● Drop.
DML statements:
● SELECT: The statement “SELECT” is used to get data from the database.
● INSERT: The statement “INSERT” is used to add a new record to the database.
● DELETE: The database can be cleaned out by using the statement DELETE.
● UPDATE: This statement is used to modify the database’s information.
Database Query
Query is a computer languages. In order to describe the data structure and to modify the data
in the database, queries are used as instructions. Query can extract particular data from a
database. We can filter and join data from various tables with the help of a query. By using the
criteria you supply query will filter the data.
Select Statement
A select query is a language in a database that displays data in Datasheet view. Data from
tables is displayed by a query rather than being stored by it. A query may display data from one
or more tables, from other queries, or from both of these sources simultaneously.
25 Soap 40 80
31 Powder 80 30
45 Shampoo 250 25
Output –
25 Soap 40 80
31 Powder 80 30
45 Shampoo 250 25
Output –
Product_Name
Soap
Powder
Shampoo
Soap Box
Output –
Product_Name Price
Soap 40
Powder 80
Shampoo 300
25 Soap 40 80
31 Powder 80 30
45 Shampoo 250 25
Output – 235
Question – Display the total amount of each item. The amount must be calculated as
the price multiplied by quantity for each item.
Output –
25 Soap 3200
31 Powder 2400
45 Shampoo 6250
Output – 58.75
25 Soap 40 80
31 Powder 80 30
45 Shampoo 250 25
Question – Write a Query to display the product whose price is less than 90
Output –
25 Soap 40 80
31 Powder 80 30
Output – 6250
Or
Output –
Product_No Product_Nam Price*Quantity
45 Shampoo 6250
Question – Write a Query to display the data whose quantity is equal to 80.
Output –
25 Soap 40 80
Select * from product where Price >= 40 and Price <= 120;
Output –
25 Soap 40 80
31 Powder 80 30
31 Powder 80 30
45 Shampoo 250 25
Or
Output –
31 Powder 80 30
45 Shampoo 250 25
25 Soap 40 80
Or
25 Soap 40 80
31 Powder 80 30
45 Shampoo 250 25
Output –
45 Shampoo 250 25
31 Powder 80 30
25 Soap 40 80
UPDATE statement
To edit or update already-existing records in a table, use the UPDATE statement. Using the
WHERE clause, you can either define a specific subset of entries to edit or use it to update
everything at once.
Soap 40 80
Powder 80 30
Shampoo 250 25
Output –
Soap 40 80
Powder 80 30
Shampoo 300 25
Question – Write a Query to update the Quantity of Powder in the product table.
25 Soap 40 80
31 Powder 80 50
45 Shampoo 250 25
Output –
To create a new table in the database you can use Create Table Command.
Field DataType
Product_No Integer
Product_Name Varchar(20)
Price Integer
Quantity Integer
Create table product ( Product_No Int, Product_Name Varchar(20), Price Int, Quantity
Int);
Output –
Insert statement is primarily used to add a single or more rows to the target table.
Or
25 Soap 40 80
31 Powder 80 30
45 Shampoo 250 25
Question – Write a Query to add a new row with the following details
25 Soap 40 80
31 Powder 80 30
45 Shampoo 300 25
Output –
Forms
The Form allows you greater control over your outcomes. The form allows you to customize
various parts of the form’s design and then generates a form based on your instructions.
A report helps in the presentation of data in a summarized format. It is utilized to create a clear
format for the entire work product. In the database, you can build reports.
Steps To Create Report Using Wizard
https://cbseskilleducation.com/database-management-system-class-10-mcq/