Jump to content

Two tables with two different structures, need one query


Kinsbane

Recommended Posts

Hi all!

 

I have two different tables, with no common fields, to be queried in one query and have the query return one resultset. The reason for this is I am working on a web app that displays listings of files from both tables. I don't want to have two separate queries because then the data from one table will be given precedent over data from another table (I think).. I also don't want to have to use a CRON job to populate a separate table every hour, as these records get updated frequently.

 

So, I am hoping there's a way to query two tables with no common fields to generate a single result set that I can then display to the end user.  The version of MySQL I have for now is 3.23, although the new webserver we're installing has latest MySQL 5.

 

Thank you very much in advance for any assistance!

Looks like UNION is the way I need to go, but MySQL 3.xx doesn't support it, as we're not using our PHP/MySQL5 server yet. I found this link as a work-around:  www.codewalkers.com/c/a/Database-Articles/Writing-UNION-statements-in-MySQL-3x/ but I can't seem figure out where I put in my conditionals for which rows I want to extract from each table...

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.