how many type of subquery?
Answers were Sorted based on User's Feedback
Answer / rajkumar
As database developer, you must have ever written
subqueries in either SQL Server or any other database
platform. This article will describe shortly about types of
subquery.
A subquery is inner query that will be used by outer query.
A subquery could return scalar value or a series of value.
Based on query dependency, a subquery could be self-
contained or correlated one. A self-contained subquery is a
subquery independent from outer query, and correlated
subquery is a subquery that is referencing to a row in
outer query.
Self-contained subquery is easier to debug than correlated
subquery. And it is executed only once whereas correlated
subquery is executed once for each row of outer query.
Sample of self-contained subquery that returns scalar value
is shown below :
Select customerid
From dbo.orders
Where employeeid = (select employeeid from dbo.employees
where lastname = ‘RAJ’);
This query returns customers list whose employee is RAJ.
Is This Answer Correct ? | 9 Yes | 1 No |
how do you implement one-to-one, one-to-many and many-to-many relationships while designing tables? : Sql server database administration
how to trace the traffic hitting a sql server? : Sql server database administration
How to provide Security for package?
How to create new tables with "select ... Into" statements in ms sql server?
Can I delete event logs?
Can a unique index be created on a column, which contains null?
Is sql server a database?
What will you do If the low Performance occurs?
How to read data in a table with "select" statements?
How to modify the underlying query of an existing view?
What are the approximate numeric data types?
Can we use max in where clause?