GeeCON Prague 2014*
The moose likes JDBC and the fly likes Doubt regarding joins in SQL... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Databases » JDBC
Bookmark "Doubt regarding joins in SQL..." Watch "Doubt regarding joins in SQL..." New topic
Author

Doubt regarding joins in SQL...

Vinod Vijay
Ranch Hand

Joined: Sep 13, 2011
Posts: 137

There are two tables company and employee in my database. Emp_id is the only primary_key inside employee table and company_id is the only primary key inside company table. Both company and employee tables have relationship such that Emp_id of employee table acts as a foreign key inside company table. Now my question is what kind of join is below in oracle:-


Secondly how many joins are there in oracle? I know about following:-
Join (or, inner join)
Left join (or, Left outer join)
Right join (or, Right outer join)
Full join


Are these joins differ when it comes out to be other databases like mysql or sql server in terms of its number or same, only the terminology is different?

I used to apply such joins(shown above) everywhere but never knew in which category it belongs to? What I think is that it does not belongs to left and right joins and not sure about full join. I think may be it belongs to inner join because it will return records if at least there is match on both tables else will not. If I'm right here (means it does belong to inner join) then I have read the syntax on http://www.w3schools.com that following is the syntax for inner join which different what I'm applying like shown above:-



Please clear my doubts about all joins by explaining these with simple example.




Vinod Vijay Nair
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18570
    
    8

In my opinion Wikipedia is technically superior to w3schools; here's their article about Join (SQL).
Vinod Vijay
Ranch Hand

Joined: Sep 13, 2011
Posts: 137

Paul Clapham wrote:In my opinion Wikipedia is technically superior to w3schools; here's their article about Join (SQL).


what about my question especially about syntax which I have used ? Please explain that.
Martin Vajsar
Sheriff

Joined: Aug 22, 2010
Posts: 3610
    
  60

The article linked by Paul has plenty of examples. If you don't understand something there, feel free to ask a specific question.

As per your question: the join you has shown us in the first example is the inner join.

More resources on joins:
http://docs.oracle.com/cd/B19306_01/server.102/b14200/queries006.htm
http://docs.oracle.com/cd/B19306_01/server.102/b14200/statements_10002.htm#i2080416
Discussion on AskTom site


 
GeeCON Prague 2014
 
subject: Doubt regarding joins in SQL...