Posted inProgramming / Mysql / Mysqli / php

PHP SQL INNER JOIN Query on Multiple Tables

PHP SQL INNER JOIN Query on Multiple Tables

Today, We want to share with you PHP SQL INNER JOIN Query on Multiple Tables.
In this post we will show you SQL INNER JOIN Multiple Tables example, hear for PHP SQL INNER JOIN query on multiple tables we will give you demo and example for implement.
In this post, we will learn about SQL join three or more tables with an example.

Syntax of INNER JOIN Multiple in MYSQL


select *
from tableA a
inner join tableB b
on a.common = b.common 
inner join TableC c
on b.common = c.common

Example 1 : SQL INNER JOIN Multiple Tables example

SELECT p.pagename
, p.pageid
, p.pagedesc
, p.pagetitle
, u.username
, u.useremail
FROM pages p
INNER JOIN cart ct on p.pageid = ct.pageid
INNER JOIN users u on ct.userid = u.userid

Example 2 : Joining Three or More Tables

table1 = users
table2 = pages
table3 = product
primaryKey = userid

SELECT * 
FROM users INNER JOIN pages ON 
users.userid=pages.table1Id INNER JOIN 
product ON users.userid=product.table1Id

Example 3 : JOIN three tables


SELECT A.* FROM TableA A
LEFT OUTER JOIN TableB B ON (A.id = B.a_id)
LEFT OUTER JOIN TableC C ON (A.id = C.a_id)
WHERE B.a_id IS NOT NULL OR c.a_id IS NOT NULL
  

Example 4 : Simple Example of SQL INNER JOIN


SELECT  u.userid,
u.usernm,
ut.crdr,
a.advertnm,
a.advertlogo
FROM    usermst u
INNER JOIN usertransactions ut ON u.userid = ut.userid
INNER JOIN adverts a ON a.advertsid = ut.advertsid 
where ut.usertransid=98566

I am Jaydeep Gondaliya , a software engineer, the founder and the person running Pakainfo. I'm a full-stack developer, entrepreneur and owner of Pakainfo.com. I live in India and I love to write tutorials and tips that can help to other artisan, a Passionate Blogger, who love to share the informative content on PHP, JavaScript, jQuery, Laravel, CodeIgniter, VueJS, AngularJS and Bootstrap from the early stage.

Leave a Reply

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

We accept paid guest Posting on our Site : Guest Post Chat with Us On Skype