#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2000
    Location
    UK
    Posts
    27
    Rep Power
    0
    I have several news tables. Each one is structured the same for the moment, apart from the primary key. For example:

    WorldNews
    =========
    WorldNewsID | Headline | Article


    TownNews
    ========
    TownNewsID | Headline | Article

    I want to be able to select all the articles from both tables together - to put them into one table so to speak, with the NewsID value being taken from the appropiate *NewsID column of each table.

    Hope that's clear! Just read over it and it might not be. Hope somebody understands...

    Ben.
  2. #2
  3. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Posts
    29
    Rep Power
    0
    I've had a similar situation this week. Union is not supported (yet), so the dreaded temporary table came to the rescue. Insert both sets of data into the one temp table and then do your select from there. If your primary keys overlap, then create an extra auto_increment column on the temp table.
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2000
    Location
    UK
    Posts
    27
    Rep Power
    0
    Thanks for your advice.

    However, when I try and carry out a query including CREATE TEMPORARY TABLE - I keep getting errors in my syntax. However, when I remove the TEMPORARY from the statement, it is carried out okay.

    Basically, I am looking for somewhere on the web that gives me some advice on creating and using temporary tables with php3... not much to ask I hope (!) but the book I have is next to useless.

    Thanks,
    Ben.

Similar Threads

  1. placing results into separate tables
    By sph33r in forum PHP Development
    Replies: 4
    Last Post: June 23rd, 2004, 09:03 PM
  2. select across multiple tables (UNION)
    By vickistanfield in forum MySQL Help
    Replies: 3
    Last Post: September 26th, 2003, 09:05 PM
  3. separate quries to separate tables within php
    By wivellJ in forum PHP Development
    Replies: 2
    Last Post: September 25th, 2003, 10:19 AM
  4. output 1 column into separate html tables
    By trishaDawn in forum ColdFusion Development
    Replies: 2
    Last Post: June 13th, 2003, 03:02 PM
  5. union of 2 tables?
    By Solmyr in forum MySQL Help
    Replies: 2
    Last Post: October 15th, 2002, 04:51 PM

IMN logo majestic logo threadwatch logo seochat tools logo