SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Zealot
    Join Date
    Jan 2009
    0 Post(s)
    0 Thread(s)

    Inbox from 2 tables

    I would like to show all new messages and invitations (friend requests) in 1 page (Inbox) mixed together like this:
    Person Message title Date
    Nick Hi, how are you? 25.12.2010
    Linda Goint out tonight 25.12.2010
    Mark Mark invited you to his network 25.12.2010

    A structure of messages is the following:

    Invitations will be in another table and it will have only 4 fields:
    id | from | to | to_viewed | to_deleted | date | status

    Please could you advise me what would be the best choice for this, how to put those tables into 1 query. Join, UNION or something else?

    Thanks a lot

  2. #2
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Toronto, Canada
    63 Post(s)
    3 Thread(s)
    use a UNION

    each of the two SELECTs in the UNION will require a join, from the from/to column to the users table to get the name | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts