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

IN - LIKE - Corr - Queries: SQL - 230 Page 1

SQL

Uploaded by

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

IN - LIKE - Corr - Queries: SQL - 230 Page 1

SQL

Uploaded by

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

IN_LIKE_Corr_Queries

IN
The IN operator compares a value to a list of specified values.
The IN operator returns true if the compared value matches at least one value in the list; otherwise, it returns
false.

finds all employees who work in the department 10 or 20.

LIKE
The LIKE operator compares a value to similar values using a wildcard operator.
SQL provides two wildcards used in conjunction with the LIKE operator:
 The percent sign ( %) represents zero, one, or multiple characters.
 The underscore sign (_) represents a single character.

1. Finds all employees whose first name starts with the string Jo
2. Find all the employees whose job start with A

3. finds all employees with the first names whose the second character is 0:

SQL_230 Page 1
4. finds all employees with the empno ends with 8:

5. Find all employee with 4 letter names

Some more operators will be discussed after subquery topic and aliasing topic

- A subquery, or nested query, is a query placed within another SQL query.


- When requesting information from a database, you may find it necessary to include a subquery into the SELECT, FROM , JOIN,
or WHERE clause. However, you can also use subqueries when updating the database (i.e. in INSERT, UPDATE,
and DELETE statements).
- syntax :
Outerquery(
innerquery
)
Q : Display all employees working in depttno 10
Q : No Subquery : select * from emp where deptno=10
With subquery : select * from emp where deptno = (select deptno from dept where deptno=10)

Generally the outer query runs with the result of the innerquery

There are several types of SQL subqueries:


 Scalar subqueries return a single value, or exactly one row and exactly one column.

 Multirow subqueries return either:

SQL_230 Page 2
 Multirow subqueries return either:
o One column with multiple rows (i.e. a list of values), or
o Multiple columns with multiple rows (i.e. tables).

 Correlated subqueries, where the inner query relies on information obtained from the outer query.

SQL_230 Page 3

You might also like