Difference between subquery and coquery

Showing Answers 1 - 7 of 7 Answers

Minhajul Islam

  • Jun 14th, 2006
 

A subquery is called a query with in the query. Such as

select n1,n2 from table1 where in n1 not in(select n1 from table2)

while main query is the only query like

select n1,n2 from table1

  Was this answer useful?  Yes

kiran

  • Nov 30th, 2006
 

Subquery: The subquery will be executed once for all the rows of main query but the co query/co related query will be executed for each selected row of main query.

Suppose 10 rows are returened from main query ,then sub query will be executed only once but the co query will be executed 10 times.

Subquery: Select a from table1 where a in(select aa from table2);

co query: Select a from table1 where p=(select pp from table2 where aa=table1.a)

  Was this answer useful?  Yes

kumaran.vijay

  • Dec 22nd, 2006
 

Subquery:-

A subquery is the query which contains inner query and outer query where the inner query is excuted first and send the output to the outer query

Eg:- select * from t1 where t1.c1 in (select t2.c1 from t2)

A coquery is the query which contains inner query and outer query where the inner query is excuted first and send the output to the outer query 

Eg:- select * from t1 where t1.c1 > (select t2.c1 from t2 where t1.c3= t2.c3)

T1 = Table Name, C1,C3 are the column names

  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