MYSQL help

Discussion in 'PHP' started by scifin, May 15, 2008.

  1. #1
    Hi
    Quick question
    Using php / mysql.
    I am looking for a mysql statment that will pull information from 2 tables.
    The tables are unrelated one is news, one is other artilces.

    They both have a DATE column and I would like to order the articles / news in date order.

    I cannot JOIN the tables as there is no common ground.

    I just need to get

    article 100
    article 99
    news 18
    article 98
    news 17
    news 16

    style output.

    (I have the PHP in order already to manage the mixed tables)

    Any help - this should be really simple.
     
    scifin, May 15, 2008 IP
  2. gauravgrt

    gauravgrt Peon

    Messages:
    2,035
    Likes Received:
    129
    Best Answers:
    0
    Trophy Points:
    0
    #2
    i dont know if union query is can do the needful, but you can try it.

    SELECT ARTICLE FROM TABLE1
    UNION ALL
    SELECT NEWS FROM TABLE2
     
    gauravgrt, May 15, 2008 IP
  3. scifin

    scifin Peon

    Messages:
    147
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    No - thanks for trying
    I am getting this:

     
    scifin, May 15, 2008 IP
  4. Altari

    Altari Peon

    Messages:
    188
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Are you using MySQL 5? You could create a view.

    CREATE or REPLACE VIEW articles AS
    Your query...
     
    Altari, May 15, 2008 IP
  5. scifin

    scifin Peon

    Messages:
    147
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Sorry should have said - mysql 4
     
    scifin, May 15, 2008 IP