INTERSECT clause is used in oracle and SQL Server to retrieve the data which are exists in both the tables.i.e we can say common records present in both the tables.
Syntax:
select column1, column2,....
from table 1 [where clause]
from table 1 [where clause]
intersect
select column1, column2 ...
from table2 [where clause]
from table2 [where clause]
select name, loca from table1
intersect
select name, loc from table2
it returns the following rows which are common on both tables based on columns and conditions
Ravi Hyd
Murali ca
In MySQL
select * from table1
where (column1, column2)
in (select * from table2)
or
select * from table1
where exists
(select * form table2
where table2.column1= table1.column1
and table2.column2=table1.column2)
No comments:
Post a Comment