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

How should subqueries after mysql select be used

2025-01-20 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

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

This article mainly tells you how to use the sub-query behind mysql select, related technical terms you can check online or find some related books to supplement, here will not dabble, we will go straight to the topic, hope that the sub-query behind mysql select How to use this article can bring you some practical help.

The subquery after select is used and can only be scalar query.

#Case: Query the number of employees in each department

SELECT d.*, ( SELECT COUNT(*) FROM employees WHERE employees.` department_id`=d.department_id)FROM departments d;

#Case: Query department name with employee number =102

SELECT department_nameFROM employees eINNER JOIN departments dON e.` department_id`=d.` department_id`WHERE e.` employee_id`=102;

subquery

SELECT (SELECT department_nameFROM employees eINNER JOIN departments dON e.` department_id`=d.` department_id`WHERE e.` employee_id`=102

);

How to use the sub-query behind mysql select will be mentioned to you first. For other related issues, you can continue to pay attention to our industry information if you want to know. Our section content captures some industry news and expertise to share with you every day.

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