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
Solved

Explain JOIN

Posted on 2004-09-18
7
578 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
Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

This article will explain how to display the first page of your Microsoft Word documents (e.g. .doc, .docx, etc...) as images in a web page programatically. I have scoured the web on a way to do this unsuccessfully. The goal is to produce something …
This article discusses how to create an extensible mechanism for linked drop downs.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to dynamically set the form action using jQuery.

808 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