0% found this document useful (0 votes)
7 views1 page

SQL Commands

Uploaded by

editzrj671
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views1 page

SQL Commands

Uploaded by

editzrj671
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

condition based on pattern matching:

keyword: LIKE
wild card characters:
%(percentage) : zero or many characters
_(underscore) : single character

Q: WAC to display employee id, employee name, salary and department number of all
the employees whose name start with A?
Ans: Select eid, ename, salary, deptno from emp where ename LIKE "a%";

Q: WAC to displat details of all the employees who have 3rd letter as 'm' in
his/her name?
ans: Select * from emp where ename like "__m%";

ORDER BY CLAUSE:
orderby clause is used to arrange the table in ascending or in descending order.
SORTING
BY default : Ascending order (ASC)
descending order : (DESC)
SYNTAX:
Select <list of columns>
from <table name>
where <condition>
order by [<field name 1 ASC/DESC , Field Name 2 ASC/DESC..........]);

Q: WAC to arrange the table employee in ascending order of their names?


Ans: Select * from emp order by ename;

Q: WAC to display employee name, their salary and designation of all the employees
who are male in descending order of their salary?
Ans: select ename, salary, desig from emp where gender='M' order by salary desc;

UPDATE COMMAND:
UPDATE command specifies the rows to be changed using where clause and the new
data using the SET keyword.
SYNTAX:
UPDATE <Table name>
SET <column name>=<values to be modified>
WHERE <Condition>;
Q: WAC to change the designation of all employees with "TEACHER"?
ANS: UPDATE emp set desig="teacher";

Q: WAC to change the salary of all the employees with 15500 whose department number
is 20?
Ans: UPDATE emp set salary = 15500 where deptno=20;

You might also like