Get the App
SLTechnology News&Howtos  ›  Database  › 

How to use SELECT statement in SQL

Shulou Source: shulou.com Published: 2022-05-31 18:57:49 09月15日 Update

I believe many inexperienced people don't know what to do about how to use the SELECT sentence in SQL. Therefore, this paper summarizes the causes and solutions of the problem. Through this article, I hope you can solve this problem.

What are the uses of SQL nested SELECT statements

1. Single-row subquery: single-row subquery means that the returned result of the subquery has only one row of data. Single-line comparison symbols (=, >, =, =, selectstNamefromStudentwherestIdin (selectdistinctstIdfromscorewhereteId= (selectteIdfromteacherwhereteName='Rona')) can be used when subquery results are referenced in the conditional statement of the main query statement

To enquire about the information of all departments numbered A:

SELECTename,job,salFROMEMPWHEREdeptnoin (SELECTdeptnoFROMdeptWHEREdnameLIKE'A%')

2)。 Multi-line subquery uses ALL operation symbol example: query the name of a student with more than one score higher than the highest score of Kaka:

Sql > selectstNamefromStudentwherestIdin (selectdistinctstIdfromscorewherescore > all (selectscorefromscorewherestId= (selectstIdfromStudentwherestName='Kaka')

3)。 Multi-line subquery uses ANY operation symbol example: query the name of a student who has more than one score higher than any one of the Kaka:

Sql > selectstNamefromStudentwherestIdin (selectdistinctstIdfromscorewherescore > any (selectscorefromscorewherestId= (selectstIdfromStudentwherestName='Kaka')

What are the uses of SQL nested SELECT statements

3. Multi-column subquery: when it is a single-row and multi-column subquery, the single-row comparison symbol (=, >, =) can be used when the subquery result is referenced in the conditional statement of the main query statement.

Tags: Queries statements multiple lines results symbols grades conditions examples names students one content operators data methods more questions columns zygotes highest Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno NVidia Apple Docker Shulou Tech Info vpn