bcamp1973 Posted October 30, 2006 Share Posted October 30, 2006 i'm building a simple website CMS. on loading a page the database is queried for the page details. the query hits 3 tables..."pages","images" and "links". Can i write a single query to grab all the needed data from all 3 tables to build the page? The "images" table contains one or more images for each page, and teh "links" table contains one or more links for each page. The tables look like so...pages-------------idpage_titlepage_pictures-------------idpicture_idpage_idlinks-------------idpage_idlinkI'm using MySQL 4.1.15. So far i've only been able to get all this data using 3 separate queries. Not sure if that's considered "messy" or if it's really the only way to go? Quote Link to comment https://forums.phpfreaks.com/topic/25625-writing-smart-multi-table-queries/ Share on other sites More sharing options...
fenway Posted October 31, 2006 Share Posted October 31, 2006 Well, if you need all the pictures & links for a given page, you'd need two statements right there (I consider UNION still 2 statements, but you could get away with a single UNION statement). You'd have to JOIN in the pages table to be sure, but that's still not any less "messy", as you put it. Quote Link to comment https://forums.phpfreaks.com/topic/25625-writing-smart-multi-table-queries/#findComment-117473 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.