Results 1 to 3 of 3

Thread: SQL Help

  1. #1
    Join Date
    Oct 2011
    Posts
    71

    Unanswered: SQL Help

    I have two tables tbl_Notification and tbl_EventNotification, joined together

    tbl_Notification is a list table and tbl_EventNotification is a junction table between the list and main table.

    tbl_Notification
    NotificationID

    tbl_EventNotification
    EventID
    NotificationID

    Say I have 5 entries in tbl_Notification.

    Home
    Business
    Cell
    Fax
    Email

    And I have 2 entries for a specific EventID in tbl_Notification

    Home "No Answer"
    Cell "Bob"

    What I want displayed is

    Home "No Answer"
    Business
    Cell "Bob"
    Fax
    Email

    Everything I have attempted to do has either only given me the two enteries or gives me entries from other EventID.

    Can anyone help me with how to get this desired outcome with a SQL statement?

    Thanks for your time, thoughts and knowledge!

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    use a LEFT OUTER JOIN
    Code:
    SELECT tbl_EventNotification.EventID
         , tbl_Notification.NotificationID
      FROM tbl_Notification
    LEFT OUTER
      JOIN tbl_EventNotification
        ON tbl_EventNotification.NotificationID = tbl_Notification.NotificationID
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  3. #3
    Join Date
    Oct 2011
    Posts
    71
    Thanks for the reply works perfectly. Genius me forgot the "ON" portion of the sql syntax, I'm feeling smart today

    Thanks for the time to answer a silly question!

Posting Permissions

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