SELECT
This command is used to retrieved or accessed the desired records from
table(s). This is very important command and mostly used.
Syntax:
SELECT
column1,column2,... FROM table-name WHERE
conditions [operators]
Examples:
SELECT *FROM employee
This command show all records of table
employee. Use *before FROM mean all records. And there is no special criteria
for filtering records. If you want to select the total salary paid for its
employees more than 20000, the SQL query would be like:
SELECT *FROM employee WHERE salary > 20000
If salary paid for its employees more than 20000, and less than 30000 the SQL
query would be like:
SELECT *FROM employee WHERE salary >
20000 AND salary < 30000
If you want the followng result then apply command as
Full Name
----------------
Abdul Hamid
Ghulam Hussain
SELECT first_name+Last_name as "Full Name" FROM
student
The following command shows top 20 percent of recrod from the table student
SELECT TOP 20 PERCENT *FROM student
The following command shows the Reg_No of those students who have age between 20 to 40
SELECT Reg_no FROM student WHERE age >= 20 and age <= 40
No comments:
Post a Comment