0% found this document useful (0 votes)
20 views

Select, Insert, Update, Delete

sql

Uploaded by

Ujala Aleem
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views

Select, Insert, Update, Delete

sql

Uploaded by

Ujala Aleem
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 9

SQL

Select, Insert, update , delete


Introduction to SQL
SQL is a standard language for accessing and manipulating databases.
• SQL stands for Structured Query Language
• SQL lets you access and manipulate databases
• SQL can execute queries against a database
• SQL can retrieve data from a database
• SQL can insert records in a database
• SQL can update records in a database
• SQL can delete records from a database
Select command
• It is used to select a set of data or information from a table
• We can view set of information or retrieve information

Syntax : SELECT * FROM table_name;


Command: SELECT * FROM customers;

These commands will show records. The table should not be empty, if it is
empty it will give an error.
Insert command
• It is used to add new records or row to a table

Syntax : INSERT INTO table_name


VALUES (value1, value2,….);

Values are automatically added to the columns in the table. Orders of


the column in the table matters. We have to remember the order of the
table.
Command: INSERT INTO Products (ProductName, productID,
SupplierID,CategoryID,Unit,Price) VALUES ("Bilal",78,15,2,10,4);
Update Command
• It is used to change or update or modify the existing data in the table

Syntax :
UPDATE table_name SET column_name1 = value1, column_name2 =
value 2….. WHERE condition;

In this command “WHERE” clause is very important. You have to use


this clause whenever updating table.
• Lets change “EmployeeID” of “OrderID 10248” from 5 to 10
Command:
UPDATE orders SET EmployeeID = 10 WHERE OrderID = 10248;
Delete command
• This will delete the data or table

Syntax:
DELETE FROM table_name WHERE Condition

In this command “WHERE” clause is very important. You have to use


this clause whenever updating table.
Command: DELETE FROM categories WHERE CategoryID = 2;

You might also like