Solved

Explain JOIN

Posted on 2004-09-18
7
575 Views
Last Modified: 2013-12-12
Explain JOIN and how to use it in non mysql guru terms.
0
Comment
Question by:chilled2003
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
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

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…
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn how to dynamically set the form action using jQuery.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

708 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now