Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Multi-table query and group function of SQL statement in Orancle

2025-02-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

1. SQL's multi-table query:

1. Left connection and right connection (unimportant party plus (+))

SELECT e.empnoree.enamered.deptnored.dnamered.dnamered.loc FROM emp esanct d WHERE e.deptno (+) = d.deptno

(+) on the left side of the equal sign, there is a right connection, and vice versa.

2. Cross-connect (CROSS JOIN produces Cartesian product)

SELECT * FROM emp CROSS JOIN dept

3. Natural connection (NATURAL JOIN) automatic association field matching

SELECT * FROM emp NATURAL JOIN dept

4. USING clause, directly related operation column (not commonly used)

SELECT * FROM emp e JOIN dept d USING (deptno) WHERE deptno=30

5. ON clause, and users specify the connection conditions themselves.

SELECT * FROM emp e JOIN dept d ON (e.deptno=d.deptno) WHERE deptno=30

Second, group functions:

1. Commonly used: COUNT () MAX () MIN () AVG () SUM ()

Use conditions, 1. GROUP BY exists in the program, and grouping conditions are specified. 2. Use grouping functions alone except for equality conditions. Grouping functions use HAVING conditions.

Formula:

SELECT {DISTINCT} column FROM table {WHERE (s)} {GROUP BY {HAVING grouping condition}} {ORDER BY sort field ASC | DESC, sort field ACS | DESC, … }

Grouping: there are duplicates on a column, which can be used in nesting

= ANY equals IN is smaller than the maximum, > ALL is larger than the maximum,

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report