AbydosGater Posted July 16, 2007 Share Posted July 16, 2007 Hi, Im having some trouble using table joins to pull plugin data and block data for my site all at once in one query. Im using the following query: SELECT `sb_blocks`.`bID`, `sb_blocks`.`title`, `sb_blocks`.`bFile`, `sb_plugins`.`pDir`, `sb_plugins`.`pFile` FROM `sb_blocks`, `sb_plugins`, WHERE `sb_blocks`.`pluginID` = `sb_plugins`.`pID` AND `sb_plugins`.`status` = 'init' ORDER BY `sb_blocks`.`priority` Its not getting any results. The data is there. But when i run it via PhpMyAdmin i get the following error: #1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE `sb_blocks` . `pluginID` = `sb_plugins` . `pID` AND `sb_plugins` . `stat' at line 1 But i dont know. I cant see where im going wrong. Im sorry if its simple its the first time i have normalised my data this much and used multiple tables in one statment. 3:30 AM now but im trying to get this finished before tomorrow. Can anyone spot the error? Thanks Andy Quote Link to comment https://forums.phpfreaks.com/topic/60145-solved-query-using-multiple-tables/ Share on other sites More sharing options...
pocobueno1388 Posted July 16, 2007 Share Posted July 16, 2007 You have a comma in there that shouldn't be. Try this: <?php SELECT `sb_blocks`.`bID`, `sb_blocks`.`title`, `sb_blocks`.`bFile`, `sb_plugins`.`pDir`, `sb_plugins`.`pFile` FROM `sb_blocks`, `sb_plugins` //<---comma was here WHERE `sb_blocks`.`pluginID` = `sb_plugins`.`pID` AND `sb_plugins`.`status` = 'init' ORDER BY `sb_blocks`.`priority` ?> Quote Link to comment https://forums.phpfreaks.com/topic/60145-solved-query-using-multiple-tables/#findComment-299197 Share on other sites More sharing options...
AbydosGater Posted July 16, 2007 Author Share Posted July 16, 2007 Heh! Thank you so much. It could have taken me the rest of my life to notice that. Andy Quote Link to comment https://forums.phpfreaks.com/topic/60145-solved-query-using-multiple-tables/#findComment-299534 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.