Results 1 to 2 of 2
  1. #1
    Join Date
    Aug 2011
    Posts
    1

    Lightbulb Unanswered: Left Excluding join with three tables

    Ok I've three tables

    address

    10
    20
    30
    40
    50
    60
    70
    80
    90
    100

    postaddress

    10
    20
    30
    40

    asstaddress

    10
    50


    Now I've to find out entries in the "address" table that don't have links with "postaddress" or "asstaddress"

    So the results will be

    60
    70
    80
    90
    100


    Can anyone help, I can do it with two tables as below, but can't figure out how to do the same with three tables

    Code:
    select address_sid from uk_addresses u
    left join assets a
    on u.address_sid=a.address_sid
    where a.address_sid is NULL
    Thanks

    Karthik
    Last edited by kompkar; 08-12-11 at 13:09. Reason: layout/format correction

  2. #2
    Join Date
    Jan 2004
    Location
    Croatia, Europe
    Posts
    4,094
    Provided Answers: 4
    MINUS set operator might be the simplest here:
    Code:
    select id from address
    minus
    select id from postaddress
    minus
    select id from asstaddress;

Posting Permissions

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