How is sub queries handled in MySQL?

Questions by nancyphilips   answers by nancyphilips

Showing Answers 1 - 0 of 0 Answers

amitverma

  • Sep 25th, 2008
 

Sub queries in MySQL handled nested way, You can see the example and understand yourself -

SELECT name, headofstate, population FROM Country WHERE population=(SELECT MAX(population) FROM Country);

  Was this answer useful?  Yes

Subqueries in MySQL are handled in the following way.

For e.g
Schema for sailor table :
Sid:int(2) PK
SName:varchar(15)
Rating:int(3)
Age int(3)

If you want to select name and age of oldest sailor, its query will  be as follows

SELECT Sname,Age FROM sailors WHERE Age IN (SELECT max(Age) FROM sailors)

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions