Php Flow » Php

Mysql Join With Multiple Tables

Sometimes you need to get records from more than two tables.This can be very confusing when you are not know about mysql JOIN. If you will use multiple queries or sub queries ,it will puts major load on the server.MySql has JOIN Terminology to get records from multiple tables based on conditions, with help of join we will get records in single SQL Query without extra load on server.
The Tutorial illustrate an example from ‘Mysql Join 3 Tables’ using Left Join.’ The LEFT JOIN get all records from left table with matching all records right table’.

Example:

Select App.ApplicationId, App.Name, App.ClientAssociationId, App.Category, App.Status, AK.ClientId from Application as App LEFT JOIN ClientAssociation as Ak ON AK.ClientAssociationId = App.ClientAssociationId
LEFT JOIN Client as C ON C.ClientId = AK.ClientId

In Above query we are fetching all records from application tables based on ClientAssociationId(Foreign Key) of ClientAssociation and ClientId(Foreign Key) of Client.

Did you enjoy this article? Share it!

About the Author:

Hi, This is Parvez Alam from India. I am software developer with 4 years’ experience in web development. I have submitted articles on PHP, Mysql, Magento,CSS, HTML, jQuery, web designing and social API. You can subscribe to my blog via RSS/Twitter/Google plus and Facebook. parvez1487(at)gmail(dot)com

Random Posts

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>