Jump to content

Calling multiple SQL tables at once


MillPondFN

Recommended Posts

I hope this isn't a stupid question.  I have written a fairly large site using php and SQL.  The site has multiple features (how tos, classifieds, photos, videos, ect) with each section's data housed in its own table.  Now I would like to have one highlight from each section appear in boxes on the index page simutaniously. (basically returning one random item from each table when the page is loaded)  I know how to call each table individually with sql = mysql_query, however, I fear that calling the database that many times over and over in one page load could be problematic if the site begins to get a lot of traffic.   Am I correct in worring about overloading the server and is there a better way to do this?

Link to comment
Share on other sites

To elaborate on NotionCommon's comment:

 

If your tables have common data then you can use INNER JOIN which will return the data that the selected tables have in common.

If your tables have no common data or possibly some common data then you can use FULL OUTER JOIN which will return all rows from selected tables whether or not they share common data or not.

Link to comment
Share on other sites

Thank you so much for responding.  I read into both Join and Union and I don't think either of those will work for what I want to do.  As I said before each section of the site is in a different table and each table has different column counts and data types and needs to be handled differently.  For example the row for a classified will need to show price, location, and a link to the classifieds directory where a video will need to have the code to show the video.  I was looking for something that would return all info from 1 random row in tables x,y, and z and then if from table x print this, if table y print this, ect..... Does that make sense?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.