Professional Documents
Culture Documents
Some Queries
Some Queries
the nested query should be declared into the paranthesis and it doesn't works with
the
order by clause
Que::
Write query to display name,age whose age is equal to student named 'ram' and marks
is greater than student named 'arjuna' from the table dummytable..
this is the example of nested query..
Ans::
SELECT NAME,AGE FROM DUMMYTABLE WHERE AGE=(SELECT AGE FROM DUMMYTABLE WHERE
NAME='RAM') AND
MARKS>(SELECT MARKS FROM DUMMYTABLE WHERE NAME='ARJUNA');
}//ENDS HERE
Que::
Write a query to display the dept_id of all the students from stu_dept table whose
usn in dummytable
is equal to usn in stu_dept table
Ans::
we can write the queries in two types..
1.
select dept_id from stu_dept where usn in (select usn from dummytable);
in query no. 2 we have included the both tables of which the comparision is done in
the query
and the comparision is done in the way of calling the members of objects using
object name
where object name is here table name and the member name is here the field name is
'usn'...