Results 1 to 5 of 5

Thread: SELECT <>from 2 TABLES

  1. #1
    Join Date
    Apr 2006
    Posts
    178

    SELECT <>from 2 TABLES

    I am trying to find a way to get all the different value from 2 TABLE

    SELECT DISTINCT users.name FROM users INNER JOIN localisation
    ON users.name <> localisation.name
    WHERE users.name IS NOT NULL


    i need only all the DISTINCT users.name <> localisation.name

    i dont get it with INNER LEFT RIGH FULL JOIN


    thank you for helping

  2. #2
    Join Date
    Nov 2002
    Location
    New Jersey, USA
    Posts
    3,932
    Can you clarify further with a sample. You are returning almost a cartesian product with inequality join.

  3. #3
    Join Date
    Apr 2006
    Posts
    178
    I just want to get all the users.name <> localisation.name FROM users

  4. #4
    Join Date
    Sep 2005
    Posts
    168
    --find all names in Users table that do NOT exist in Localisation table
    SELECT DISTINCT (us.name)
    FROM Users us LEFT JOIN Localisation loc ON us.name = loc.name
    WHERE loc.name IS NULL
    AND us.name IS NOT NULL
    --Find all names in Localisation table that do NOT exist in Users table
    UNION
    SELECT DISTINCT (loc.name)
    FROM Localisation loc LEFT JOIN Users us ON loc.name = us.name
    WHERE us.name IS NULL
    AND loc.name IS NOT NULL


    --HTH--

  5. #5
    Join Date
    Apr 2006
    Posts
    178
    thank you mikrOs

Posting Permissions

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