Difference between sub query and join?
If we take JOIN for two tables,to compare both table at the time with the one common field of two tables and select the query for whatever you want.
If we take SUB QUERY,first select the fields for inner query then compare the data with outside of query to check the common fields in any one of the table then produce the results.
If we take JOIN for two tables,to compare both table at the time with the one common field of two tables and select the query for whatever you want.
If we take SUB QUERY,first select the fields for inner query then compare the data with outside of query to check the common fields in any one of the table then produce the results.
for example,
difference b/w subquery and join..
---------------------sub query-------------------------
select name from tbl_college where dob not in(select dob from tbl_college where regno=1111)
name
cccc
wwww
rrrr
rrrr
---------------------join------------------------------
select * from tbl_employee as E join tbl_college as C on E.dob=C.dob
empid dob name mail mobile regno dob name course percentage
107 09/29/1983 jklu cvfd@microsoft.com 34654678 3444 09/29/1983 rrrr ece 74
-------------------------------------------------------
select * from tbl_college
regno dob name course percentage
1111 03/23/1980 bbbb cse 78
6666 02/10/1990 cccc eee 85
7888 09/16/1989 wwww it 90
3444 07/05/1996 rrrr ece 74
3444 09/29/1983 rrrr ece 74
----------------------------------------------------------
select * from tbl_employee
empid dob name mail mobile
101 03/23/1990 vvvvv ggsa@yahoo.com 25454355
105 12/24/1983 dddf kluyd@yahoo.com 874564656
120 10/28/1982 bbbg vbghn@google.com 78554324
107 06/21/1995 jklu cvfd@microsoft.com 34654678
107 09/29/1983 jklu cvfd@microsoft.com 34654678
----------------------------------------------------------