Languages

MySQL - what is subquery?

0 points
Asked by:
Lia-Perez
355

What is a subquery in MySQL?

1 answer
0 points
Answered by:
Lia-Perez
355

A subquery is a query that is nested inside statements (like SELECT , INSERT , UPDATE , DELETE) or inside another subquery.

It is used to return data that will be used in the main query as a condition to further restrict the data to be retrieved.

Practical example:

SELECT * FROM (
    SELECT * FROM `table_name` 
	ORDER BY `column_name` DESC
	LIMIT N
) subquery
ORDER BY `column_name` ASC;
0 comments Add comment
Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join