Display latest comments from 4 tables w/ different structures [mysql] [help please]

Discussion in 'Programming' started by dherald, Sep 2, 2010.

  1. #1
    Hi everyone,

    So I have 4 tables with different structures. They all have:

    - timestamp
    - the text (the actual comment I want to display)
    - a user id (which I can use to display the user's avatar)
    - a father id (which I can use to make the url)

    The problem is that in each table the name of the fields are different. For example:

    timestamp: time, timestamp
    the text: comment, text
    user id: u_id, userid
    father id: id, video_id

    Furthermore, depending on the content, the URLs would be different. So if it's a comment from the videos, the table name will be "video" and the url will be /video/id

    Can anyone please help me make a query that would display all comments in a single window? Ordered by time.

    Advice is much appreciated as I've never done such complicated queries.
     
    dherald, Sep 2, 2010 IP
  2. koko5

    koko5 Active Member

    Messages:
    394
    Likes Received:
    14
    Best Answers:
    1
    Trophy Points:
    70
    #2
    Hi, so you want to get data from a single table not from all 4?
    Please, check UNION syntax.
    Regards :)
     
    koko5, Sep 2, 2010 IP