Wednesday, April 18, 2012

Join Query in PHP




Join query is mysql...

Inner join :- In this join query there is a query for fatching the data

from more then one table according to the condition.
if we want to get the data from table1 and table2 where id of both table are equal.

$query=select * from table1 innerjoin table2 on table1.id=table2.id.

mysql _query($query);

this will gave you the result where id of table1 and table2 are equal.


Leftjoin :- In this join query there is a query for fatching the data from more then one table

according to the condition where all data of left table are show.
if we want to get the data from table1 and table2 where id of both table are equal and all data of left table1.

$query=select * from table1 leftjoin on table1.id=table2.id.

mysql _query($query);

this will gave you the result where id of table1 and table2 are equal and all data of left data are show .


Rightjoin :- In this join query there is a query for fatching the data from more then one table

according to the condition where all data of left table are show.
if we want to get the data from table1 and table2 where id of both table are equal and all data of right table1.

$query=select * from table1 Rightjoinon table1.id=table2.id.

mysql _query($query);

this will gave you the result where id of table1 and table2 are equal and

all data of right are show .

0 comments:

Post a Comment