Solved

Explain JOIN

Posted on 2004-09-18
7
579 Views
Last Modified: 2013-12-12
Explain JOIN and how to use it in non mysql guru terms.
0
Comment
Question by:chilled2003
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 4

Accepted Solution

by:
Kaarthick earned 125 total points
ID: 12090957
Basically it is the combining of two rows based on the comparative values in selected columns.

There are various types of Join like Cross-join, Equi-join, Left Join etc

Suppose if you have names of employee in a table (EMPDETAILS)with some other columns along with the employee id. and you have another table(PAYDETAILS) with the salary information having only id and not the name of the employee.

Now if you want get the emplyee name whose salaries are greater than a particualr level you have to use Joins.

For  example the query might look like,

Select EmpName from EMPDETAILS ED,PAYDETAILS PD where ED.empid=PD.empid and pd.pay>5000
0
 

Author Comment

by:chilled2003
ID: 12090970
couldnt that be done with two querys and then use php to figure it out?  obviously the join way seems to be better but is that the main reason people use it just so mysql has to do it and so there is only one query?
0
 
LVL 49

Assisted Solution

by:Roonaan
Roonaan earned 75 total points
ID: 12090980
If you would be to join it within php you'd have loads of redundant data streaming between you phpserver and your dbserver. Besides, your dbsystem is quite optimized to perform such joins in a way you could never slightly even match with the best php code you've ever written. It's kinda like letting the carpenter do the garden and the gardeneer renting do do nothing but to say which plants are which.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:chilled2003
ID: 12090988
"There are various types of Join like Cross-join, Equi-join, Left Join etc"

what are the differences?
0
 
LVL 4

Assisted Solution

by:Kaarthick
Kaarthick earned 125 total points
ID: 12091030
INNER JOIN (sometimes called the "EQUI-JOIN") where tables are combined based on a common column;

OUTER JOIN which involves combining all rows of one table with only matching rows from the other table and next week's topic; and the

SELF JOIN which is a table joined to itself
0
 
LVL 27

Assisted Solution

by:Diablo84
Diablo84 earned 50 total points
ID: 12091051
There is also LEFT and RIGHT join, as i understand it...

left join selects all of the data from the first table, and then, selects only the matching results from the second table
right join selects all of the data from the second table, and then, selects only the matching results from the first table
0
 
LVL 4

Expert Comment

by:Kaarthick
ID: 12091056
CROSS JOIN - mostly it is ignored by the users.

The LEFT and RIGHT joing works as said by Diablo84.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Generating table dynamically is the most common issue faced by php developers.... So it seems there is a need of an article that explains the basic concept of generating tables dynamically. It just requires a basic knowledge of html and little maths…
Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question