SQL Commands
SQL Commands
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 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;