PL / SQL database query

A complete SQL commands (SELECT and FROM are essential)

SELECT…

FROM…

[WHERE…

GROUP BY…

ORDER BY…]

3.1 General Queries

SELECT: column which specifies a searchable database; FROM: specifies a table or view from which to retrieve data

1.SELECT clause and the FROM clause

SELECT ORDER_NO,CONTRACT
FROM IFSAPP.SHOP_ORD A
WHERE ROWNUM=1;

Note: in the middle of the column may enter, and if necessary to adjust the position of two, the adjustment sequence can
result
Here Insert Picture Description

SELECT ORDER_NO,CONTRACT SITE
FROM IFSAPP.SHOP_ORD A
WHERE ROWNUM=1;

Note: SITE CONTRACT alias of
results
Here Insert Picture Description

SELECT ORDER_NO, REVISED_QTY_DUE/2
FROM IFSAPP.SHOP_ORD A
WHERE ROWNUM=1;

You can use an expression in the select statement
Here Insert Picture Description

WHERE clause

Conditional Expression WHERE clause conditions comprise a neutral, or may be unequal numbers may comprise an IN, NOT IN, BETWEEN, LIKE , IS NOT NULL comparison operators like conditional expression, and may also be composed of a single Conditional expression complex condition composed by logical operators.
1, WHERE clause contains a single condition
= ,! . <>, "," =, <, <=
2, the IN, the BETWEEN ... the AND, the LIKE '%', the IS NULL, the NOT;
the LIKE '% S' which represents the beginning of S
the LIKE 'W-' query to the query the beginning of the four W;
the nOT not be used alone, must be in front of any one of several operators in the front to indicate negation of the original condition.
Arithmetic operators composed expression can also be used in the WHERE clause;
the AND (represented by two simultaneous establishment); OR (optionally a can)

ORDER BY clause

Result of the query returns the result in ascending order;
DESC (this is arranged in descending order according to a)
If there are a plurality of expressions, the expressions according to a first query; only the expression of the same table, and the second expression to query only ;
likewise arithmetic symbols can also be run in this clause;

GROUP BY and HAVING in the sixth chapter

High query

Join query (this query is a plurality of tables and views)
1 Equation query
simple query: each row of data that can come from two tables;

External query: returns all rows simple query also returns a table row that do not match another table.
(+) Is a table that shows the redundant rows can also check out;
2. Non Equation queries
likely query conditions

Subqueries

Subquery is in the WHERE clause;
the SELECT command sub-query can not take ORDER BY clause

Settings Operator

UNION (This is the union)
INTERSECT (intersection)

Published 153 original articles · won praise 15 · Views 150,000 +

Guess you like

Origin blog.csdn.net/beyond911/article/details/103744449