Why is this MySQL Join Statement not Working?

Posted by Timmy on Stack Overflow See other posts from Stack Overflow or by Timmy
Published on 2010-05-04T01:29:24Z Indexed on 2010/05/04 1:38 UTC
Read the original article Hit count: 207

Filed under:
|

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>\n";
                        echo "<td>&nbsp; -- $name</td>\n";
                        echo "</tr>\n";
                    }

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

© Stack Overflow or respective owner

Related posts about mysql

Related posts about php