Solved

Explain JOIN

Posted on 2004-09-18
7
581 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
Are You Using the Best Web Development Editor?

The worlds of web hosting and web development are constantly evolving. Every year we see design trends change, coding standards adapt and new frameworks/CMS created. With such a quick pace of change it’s easy to get lost trying to keep up.

See if your editor made the list.

 

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

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

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

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…
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.
The viewer will learn how to count occurrences of each item in an array.

623 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