为什么这个MySQL加入声明不起作用?

Here is my code:

$query2 = mysql_query("SELECT * FROM categories WHERE parent = $id JOIN SELECT * FROM posts WHERE main_nav_page = '$idTwo'");

                    while ($row2 = mysql_fetch_assoc($query2)) {
                        $id   = $row2['id'];
                        $name = $row2['name'];
                        $slug = $row2['slug'];
                        $subMenuOrder = $row2['sub_menu_order'];

                        echo "<tr>
";
                        echo "<td>&nbsp; -- $name</td>
";
                        echo "</tr>
";
                    }

Is my syntax wrong?

EDIT:

the error message is:

Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /home/studentw/public_html/new_nav.php on line 30

I think there is a small syntax error. Looks like you missed the single quotes (' ') around "$id" in the WHERE parent-clause. Should be like this, I'm guessing:

SELECT * FROM categories WHERE parent = '$id' ...

Instead of that you probably want something more like:

SELECT * 
FROM 
       categories c 
    INNER JOIN 
       posts p ON c.categoryid = p.categoryid 
WHERE 
       c.parent = $id 
       AND p.main_nav_page = '$idTwo'; 

Note that the tables are joined, rather than select statements. Also, joins are specified in the FROM clause.

Try this:

$results = mysql_query("query here") or die(mysql_error());