What is a subquery in MySQL?

The examples use the students table from our MySQL tutorial: id, name, city, marks, course_id.

SELECT name, marks
FROM students
WHERE marks > (SELECT AVG(marks) FROM students);

The inner query returns the average marks (75.5), and the outer query returns the students above it: Robin, Maria, John and Asha. See MySQL Subqueries.


Learn more about the similar topics:
Tutorials
No Content Found.
Exercises & Assignments
No Content Found.
Interview Questions & Answers
No Content Found.