Friday, 9 August 2013

Joining more than 2 tables in order to loop results

Joining more than 2 tables in order to loop results

I am able to join information from 2 tables in order to output which users
said which status. It manages to get the users status from 'tbl_status'
and the username of who said it from 'tbl_users'.
But now I would also like to add the users photo alongside that status
update and output that information in the same query. Not surprisingly the
user photos are contained in 'tbl_photos'.
How can I add in this additional query into the existing out to output the
results with the last query?
$result = mysql_query("SELECT tbl_status.id as statID,
tbl_status.from_user as statFROM, tbl_status.status as statSTATUS,
tbl_status.deleted as statDEL, tbl_status.date as statDATE, tbl_users.id
as usrID, tbl_users.name as usrNAME FROM tbl_status INNER JOIN tbl_users
ON tbl_status.from_user = tbl_users.id WHERE tbl_status.deleted = '0'");

No comments:

Post a Comment