|
Custom Search
| |
|
Using subquery to return a single value (known as single-value subquery or scalar subquery) Inside This Tutorial Series
Using subquery to return a single value When the subquery returns a single value, the subquery is only evaluated once and then the value is returned to outer query to use. This kind of subqueries are also known as single-value subquery or scalar subquery. The subquery can be used in either SELECT statement or WHERE clause. In either case, an aggregate function or an expression is normally used in the subquery. When the subquery is used in WHERE clause, a comparison operator is always used. Practice #1-1: Use subquery in WHERE clause with an aggregate function. Most of the queries in the tutorials need Northwind MySQL database, you can download the database script on this page. /*
Query result set - 3 rows returned: Practice #1-2: Use subquery in WHERE clause with an aggregate function. Most of the queries in the tutorials need Northwind MySQL database, you can download the database script on this page. /*
Query result set - 25 rows returned: Practice #2: Use subquery in SELECT statement with an aggregate function. Most of the queries in the tutorials need Northwind MySQL database, you can download the database script on this page. /*
Query result set - 77 rows returned: Practice #3: Use subquery and join clause. Most of the queries in the tutorials need Northwind MySQL database, you can download the database script on this page. /*
Query result set - 1 row returned: Other tutorials in this category 1. What is subquery |
Copyright © 2024 GeeksEngine.com. All Rights Reserved. This website is hosted by HostGator. No portion may be reproduced without my written permission. Software and hardware names mentioned on this site are registered trademarks of their respective companies. Should any right be infringed, it is totally unintentional. Drop me an email and I will promptly and gladly rectify it. |
Home | Feedback | Terms of Use | Privacy Policy |