mysql syntax how to add a third table to $query

Posted by IberoMedia on Stack Overflow See other posts from Stack Overflow or by IberoMedia
Published on 2011-01-07T00:45:59Z Indexed on 2011/01/07 0:54 UTC
Read the original article Hit count: 173

Filed under:
|
|

I have code:

$query = "SELECT a.*, c.name as categoryname, c.id as categoryid".
                " FROM #__table_one as a".
                " LEFT JOIN #__table_two c ON c.id = a.catid";

                $query .= " WHERE a.published = 1"
                ." AND a.access <= {$aid}"
                ." AND a.trash = 0"
                ." AND c.published = 1"
                ." AND c.access <= {$aid}"
                ." AND c.trash = 0"
                ;

I would like to add a third table ('__some_table') for the parts of the query where a.publish, a.access and a.trash. In other words, I want these fields to be retrieved from another table, not "#__table_one", but I do not know how to incorporate the #__some_table into the current query

I imagine the JOIN command can help me, but I do not know how to code mysql

Thank you,

© Stack Overflow or respective owner

Related posts about mysql

Related posts about syntax