Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. SQL Syntax request...Please Help...

SQL Syntax request...Please Help...

Scheduled Pinned Locked Moved Database
databasehelp
7 Posts 6 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    new_phoenix 0
    wrote on last edited by
    #1

    I need to develop a query that identifies all of the records from one table that are not contained within another table. Inner Joins will not work. I know that there is an approach that will do this but I do not remember it.

    L P 2 Replies Last reply
    0
    • N new_phoenix 0

      I need to develop a query that identifies all of the records from one table that are not contained within another table. Inner Joins will not work. I know that there is an approach that will do this but I do not remember it.

      L Offline
      L Offline
      Luc Pattyn
      wrote on last edited by
      #2

      try

      SELECT * FROM table1 WHERE field1 NOT IN (SELECT field2 FROM table2 WHERE ...)

      :)

      Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles] Nil Volentibus Arduum

      Please use <PRE> tags for code snippets, they preserve indentation, and improve readability.

      1 Reply Last reply
      0
      • N new_phoenix 0

        I need to develop a query that identifies all of the records from one table that are not contained within another table. Inner Joins will not work. I know that there is an approach that will do this but I do not remember it.

        P Offline
        P Offline
        PIEBALDconsult
        wrote on last edited by
        #3

        Outer join

        D D 2 Replies Last reply
        0
        • P PIEBALDconsult

          Outer join

          D Offline
          D Offline
          Davewjones
          wrote on last edited by
          #4

          select * from table1 a left outer join table2 b on a.id=b.id where b.id is null This will give you all records in table1 that aren't in table2, assuming id is the common key.

          1 Reply Last reply
          0
          • P PIEBALDconsult

            Outer join

            D Offline
            D Offline
            David Skelly
            wrote on last edited by
            #5

            There was a thread on here a few weeks ago about the merits of exists versus in versus outer join. I can't remember what the conclusion was and I can't find the thread now.

            J P 2 Replies Last reply
            0
            • D David Skelly

              There was a thread on here a few weeks ago about the merits of exists versus in versus outer join. I can't remember what the conclusion was and I can't find the thread now.

              J Offline
              J Offline
              J4amieC
              wrote on last edited by
              #6

              Exists was better.

              1 Reply Last reply
              0
              • D David Skelly

                There was a thread on here a few weeks ago about the merits of exists versus in versus outer join. I can't remember what the conclusion was and I can't find the thread now.

                P Offline
                P Offline
                PIEBALDconsult
                wrote on last edited by
                #7

                Yes, I took part. I prefer outer join -- because of portability and such.

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups