Nested Queries
Nested Queries
Nested Query: A query within a query that has another query embedded within it
The subquery (inner query) executes once before the main query (outer query) executes.
Syntax:
Query: waq to select the name of the student who have scored minimum marks
Select sname
from stupk
where smarks=(
select min(smarks)
from stupk);
output:
LALLI
Query: waq to select the student names who have registered for the courses
Syntax:
select sname
from stupk
select sid
from coursefk );
Output:
Query: Waq to select the names of the students who have not registered the courses
Syntax:
select sname
from stupk
select sid
from coursefk );
output:
Query: Waq to select the names of the student who have registered for the course ‘DBMS’
Syntax:
select sname
from stupk
from coursefk
where cname=’dbms’);
output:
Query: select the name of the student who have enrolled the course with dbms if the course
existed in faculty table
Syntax:
Select sname
From stupk
Select sid
From coursefk
Select cname
From faculty
Output:
LITHU