Create A Table: The Following Query Creates A Table
Create A Table: The Following Query Creates A Table
shtml
n the given example we show the use of the create to make a table email and populate it
with the field named LName, FName and email_add.
To insert a new row in a database table we have to write the given below code:
employee:
Let us consider we have a table named employee which have the following records:
emp_name Position Salary email_id
Amar Designer 10000 amar@roseindia.com
Let us consider we want to insert data in field name 'emp_name', 'Position' and in
'email_id' with there specific values then we should use the following SQL statement:
If we want to change the salary to the employee with a emp_name of "Amar" then we
should use the following SQL statement :
Syntax:
for example:
UPDATE Person SET Salary = 10000
WHERE emp_name = 'Amar';
UPDATE employee
SET email_id = 'amar@newsindia.com', Position = 'Programmer'
WHERE emp_name = 'Amar';
The DELETE statement is used to delete rows from a table. database will update that is
why deletion and insertion of data will be done.
Syntax
Person:
To Delete a Row :
Result
To Delete All the Rows : This means that the table structure, attributes, and indexes will
be drop.
DELETE FROM table_name
Syntax:
SELECT column_name(s)
FROM table_name
Example: To select the content of columns named "LName" and "FName", from the
database table called "email", use a SELECT .
Select All Columns: To select all columns from the "email" table, use a * symbol
instead of column names.
WHERE clause is used with the SELECT keyword. ' Where' is a clause which is used for
searching the data with a particular condition.
If the data in the table matches condition then it returns the specific value of that
particular data.
Syntax
Operator Description
= Equal
BETWEEN Between an inclusive range
LIKE Search for a pattern
IN If you know the exact value you want to
return for at least one of the columns
WHERE in SQL:
In this section we are going to illustrate aggregate function, with the help of which we
can use many arithmetic operation like average, count, maximum and many more in
SQL. They are briefly described and denoted by the keyword in the given below section.
AVG
COUNT
MAX
MIN
SUM
For all of the above given function the standard code syntax will be:
For example we just take a Employee table and use the aggregate function SUM on the
field "Salary" to find out the total salary of the Employee table.
Table Employee:
To find out the total salary of the company's employee we should write the following
code:
SELECT SUM (Salary) FROM Employee;
When we run the above query we will get the following result:
SUM(Salary)
55000