princeads Posted March 6, 2008 Share Posted March 6, 2008 Hi guys, Could anyone help with this problem - I have a MYSQL database that uses PHP to create a dynamic website. The menu is built from the database in a table called cmsmenus, with a table called cmspages that uses the cmsmenu id as a foriegn key. I've attached my sql statement below: $sql = "SELECT m.id, m.label, m.link_url, m.parent_id, m.topmenu, m.leftmenu FROM cmsmenu m LEFT JOIN cmspages p ON p.menu_ID = m.id AND p.statusID = 1 ORDER BY m.parent_id, m.orderid ASC"; Hopefully this helps explains the scenario, at the moment all results in the cmsmenu table are retrieved which is great, but the "AND p.statusID = 1" doesn't seem to be working. Even if the corrsponding row in cmspages has value 2 the query still retrieves it, which ideally I don't want! Any help on this would be great. cheers AB Quote Link to comment Share on other sites More sharing options...
frijole Posted March 6, 2008 Share Posted March 6, 2008 just a question about your query. what is the function of the "m." before the columns? Quote Link to comment Share on other sites More sharing options...
princeads Posted March 6, 2008 Author Share Posted March 6, 2008 Hiya, the m. is for later when I start to reference columns in the cmspages table therefore p. will be used. I've been looking into the join statement, and not being expo status in the joins department, I'm thinking it might be the incorrect type of join, but don't quote me! Cheers for the help, any further is much appriciated. AB Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.