Home Database Mysql Tutorial SQL学习(持续更新)

SQL学习(持续更新)

Jun 07, 2016 pm 05:42 PM
study renew

1、having筛选分组 正如where子名限制了select显示的行数,having限制了group by显示的分组数。where查询条件在分组产生前就被计算,而having搜索条件在分组产生之后才被应用。除了having子句可以包含聚合函数以外,having语法类似于where语法。having子句可

1、having筛选分组

      正如where子名限制了select显示的行数,having限制了group by显示的分组数。where查询条件在分组产生前就被计算,服务器空间,香港服务器租用,而having搜索条件在分组产生之后才被应用。除了having子句可以包含聚合函数以外,having语法类似于where语法。having子句可以引用显示在select列表中的任何一项。

      总结:(1)where子句从from和join子句指定的运算结果中筛选行;(2)group by子句对where子句的输出进行分组;(3)having子句对分组后的结果筛选行。 

2、DBMS处理联结时,按照以下顺序执行整个查询 

(1)在join子句中应用联结条件。 

(2)在where子句中应用联结条件和查询条件。 

(3)按照group by子句对行分组。 

(4)在having子句中对分组应用搜索条件。  

(5)按照order by子句对结果排序。    

3、using子句 

      对于join语法,如果被联结的列有相同的名字且被用于比较是否相等,SQL标准定义了替代on子句的using子句。 

例如: 

select [name],[city] from [authors] inner join [publishers] using([city]);

4、使用all比较所有子查询的值 

      在子查询比较中,all修改了比较操作符,并且跟在=、、、>=之后, 表示等于、不等于、大于、小于子查询的结果中的所有值。

例如: 

select * from [table1] where [col1]>all (select [col1] from [table2]); 

5、使用any比较子查询的值 

      确定是否一个值等于、大于、小于子查询的结果中的某个值。 

6、使用exists检测存在性

       exists和not exists不比较值,而是在子查询结果中确定存在或不存在行。

例如: 

select [pub_name] from [publishers] p where exists (select * from [titles] t where t.[pub_id]=p.[pub_id] and [type]='biography'); 

7、集合操作 

(1)union返回两个查询返回的所有行,香港服务器,但会删除重复行。 

select_statement1 union [all]  select_statement2;

(2)intersect返回两个查询返回的所有共同行。

select_statement1 intersect select_statement2; 

(3)except返回第一个查询存在,但第二个查询中不存在的所有行,删除重复行。 

select_statement1 except select_statement2; 

 

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to fix Blizzard Battle.net update stuck at 45%? How to fix Blizzard Battle.net update stuck at 45%? Mar 16, 2024 pm 06:52 PM

Blizzard Battle.net update keeps stuck at 45%, how to solve it? Recently, many people have been stuck at the 45% progress bar when updating software. They will still get stuck after restarting multiple times. So how to solve this situation? We can reinstall the client, switch regions, and delete files. To deal with it, this software tutorial will share the operation steps, hoping to help more people. Blizzard Battle.net update keeps stuck at 45%, how to solve it? 1. Client 1. First, you need to confirm that your client is the official version downloaded from the official website. 2. If not, users can enter the Asian server website to download. 3. After entering, click Download in the upper right corner. Note: Be sure not to select Simplified Chinese when installing.

How to install Angular on Ubuntu 24.04 How to install Angular on Ubuntu 24.04 Mar 23, 2024 pm 12:20 PM

Angular.js is a freely accessible JavaScript platform for creating dynamic applications. It allows you to express various aspects of your application quickly and clearly by extending the syntax of HTML as a template language. Angular.js provides a range of tools to help you write, update and test your code. Additionally, it provides many features such as routing and form management. This guide will discuss how to install Angular on Ubuntu24. First, you need to install Node.js. Node.js is a JavaScript running environment based on the ChromeV8 engine that allows you to run JavaScript code on the server side. To be in Ub

Lantern and Dungeon updated on February 29: Remastered version ╳ 'Legend of Nezha' linkage Lantern and Dungeon updated on February 29: Remastered version ╳ 'Legend of Nezha' linkage Feb 28, 2024 am 08:13 AM

Lantern and Dungeons has been confirmed to be updated on February 29th. After the update, the remastered version of Lantern and Dungeons will be launched, and the remastered version will also be linked to the Legend of Nezha. The remastered version will also bring a new profession, and players can directly Job changes, dungeon content will also be expanded, new dungeon areas will be opened, etc. Mobile game update schedule Lantern and Dungeon updated on February 29th: Remastered version ╳ "Legend of Nezha" linkage version key content New profession, why are you invited to change jobs? Lamplighters can actually change jobs? Such cool equipment is really It makes people greedy. I heard that after changing jobs, the lantern holder can also learn many cool skills. Goro exclaimed: Thai pants are hot! The Legend of Nezha is coming together! Stepping on the hot wheel, holding the circle of heaven and earth in hand ♫ ~ The little heroes with both wisdom and courage: Nezha and Little Dragon Girl are about to come

Windows cannot access the specified device, path, or file Windows cannot access the specified device, path, or file Jun 18, 2024 pm 04:49 PM

A friend's computer has such a fault. When opening "This PC" and the C drive file, it will prompt "Explorer.EXE Windows cannot access the specified device, path or file. You may not have the appropriate permissions to access the project." Including folders, files, This computer, Recycle Bin, etc., double-clicking will pop up such a window, and right-clicking to open it is normal. This is caused by a system update. If you also encounter this situation, the editor below will teach you how to solve it. 1. Open the registry editor Win+R and enter regedit, or right-click the start menu to run and enter regedit; 2. Locate the registry "Computer\HKEY_CLASSES_ROOT\PackagedCom\ClassInd"

How to update MSI graphics card driver? MSI graphics card driver download and installation steps How to update MSI graphics card driver? MSI graphics card driver download and installation steps Mar 13, 2024 pm 08:49 PM

MSI graphics cards are the mainstream graphics card brand on the market. We know that graphics cards need to install drivers to achieve performance and ensure compatibility. So how to update the MSI graphics card driver to the latest version? Generally, MSI graphics card drivers can be downloaded and installed from the official website. Let’s find out more below. Graphics card driver update method: 1. First, we enter the "MSI official website". 2. After entering, click the "Search" button in the upper right corner and enter your graphics card model. 3. Then find the corresponding graphics card and click on the details page. 4. Then enter the "Technical Support" option above. 5.Finally go to “Driver & Download”

Windows permanently pauses updates, Windows turns off automatic updates Windows permanently pauses updates, Windows turns off automatic updates Jun 18, 2024 pm 07:04 PM

Windows updates may cause some of the following problems: 1. Compatibility issues: Some applications, drivers, or hardware devices may be incompatible with new Windows updates, causing them to not work properly or crash. 2. Performance issues: Sometimes, Windows updates may cause the system to become slower or experience performance degradation. This may be due to new features or improvements requiring more resources to run. 3. System stability issues: Some users reported that after installing Windows updates, the system may experience unexpected crashes or blue screen errors. 4. Data loss: In rare cases, Windows updates may cause data loss or file corruption. This is why before making any important updates, back up your

Outlook stuck updating inbox; Outlook stuck updating inbox; Mar 25, 2024 am 09:46 AM

When Outlook has problems updating your inbox, it can affect productivity. This article will introduce some simple troubleshooting steps to help you solve the problem and get Outlook back to normal. Why is Outlook always stuck updating the inbox? Outlook may be stuck updating the inbox. Common reasons include network problems, excessive mailbox capacity, and the impact of anti-virus software or firewalls. Corrupted external plug-ins or data files can also cause this to happen. Next, we'll explore these possible causes in detail and provide solutions. Fix Outlook Stuck Updating Inbox If Outlook is unable to update your inbox, please refer to the solutions listed below: Restart Outlook Disabled

How to update TikTok to the latest version How to update TikTok to the latest version Mar 27, 2024 am 11:06 AM

1. Open the Douyin app, click [Me] in the lower right corner, and click the [Three Stripes] icon in the upper right corner. 2. Select [Settings], click to enter the settings interface, find and click [General Settings]. 3. Pull down on the general settings interface, find and click [Check for Updates]. 4. If the version currently used by the user is not the latest version, an update prompt for the new version will appear. Click [Upgrade]. 5. Wait for the installation package to be downloaded. The system will automatically install it. Click [Continue Installation]. 6. If the current version is already the latest version, a prompt of "No update version available" will appear.

See all articles