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 Problem

SQL Problem

Scheduled Pinned Locked Moved Database
databasehelpquestion
5 Posts 3 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.
  • X Offline
    X Offline
    XGaMeS
    wrote on last edited by
    #1

    I have 1 table that connect 2 other table to it. I mean --> Table 1 Table 2 Table 3 IDPerson IDRelation IDWorkPlace IDPerson IDWorkPlace What I would like to know, is how can I get all the IDPerson that are not in the Table 2 ....:omg: This is not the real name of tables and fields but believe me, it must be like this. :rolleyes: I am a newbie and maybe not but who cares :eek:

    X J O 3 Replies Last reply
    0
    • X XGaMeS

      I have 1 table that connect 2 other table to it. I mean --> Table 1 Table 2 Table 3 IDPerson IDRelation IDWorkPlace IDPerson IDWorkPlace What I would like to know, is how can I get all the IDPerson that are not in the Table 2 ....:omg: This is not the real name of tables and fields but believe me, it must be like this. :rolleyes: I am a newbie and maybe not but who cares :eek:

      X Offline
      X Offline
      XGaMeS
      wrote on last edited by
      #2

      Table 1 | Table 2 | Table 3 IDPerson | IDRelation | IDWorkPlace xxxxxxxx | IDPerson | xxxxxxxx | IDWorkPlace| Sorry ;P I am a newbie

      1 Reply Last reply
      0
      • X XGaMeS

        I have 1 table that connect 2 other table to it. I mean --> Table 1 Table 2 Table 3 IDPerson IDRelation IDWorkPlace IDPerson IDWorkPlace What I would like to know, is how can I get all the IDPerson that are not in the Table 2 ....:omg: This is not the real name of tables and fields but believe me, it must be like this. :rolleyes: I am a newbie and maybe not but who cares :eek:

        J Offline
        J Offline
        Jeff Varszegi
        wrote on last edited by
        #3

        I can't understand your layout. If you're saying that it's like this, [Table 1] --------- IDPerson IDRelation IDWorkPlace [Table 2] --------- IDPerson [Table 3] --------- IDWorkPlace then you can use

        SELECT t1.IDPerson
        FROM [Table 1] t1
        WHERE
           t1.IDPerson NOT IN (
              SELECT t2.IDPerson FROM [Table 2] t2
           )

        I'd recommend against naming tables using spaces. -Jeff

        X 1 Reply Last reply
        0
        • J Jeff Varszegi

          I can't understand your layout. If you're saying that it's like this, [Table 1] --------- IDPerson IDRelation IDWorkPlace [Table 2] --------- IDPerson [Table 3] --------- IDWorkPlace then you can use

          SELECT t1.IDPerson
          FROM [Table 1] t1
          WHERE
             t1.IDPerson NOT IN (
                SELECT t2.IDPerson FROM [Table 2] t2
             )

          I'd recommend against naming tables using spaces. -Jeff

          X Offline
          X Offline
          XGaMeS
          wrote on last edited by
          #4

          Exactly what I needed :-D Thank you. And it's not the real table name and field. ;P I am a newbie

          1 Reply Last reply
          0
          • X XGaMeS

            I have 1 table that connect 2 other table to it. I mean --> Table 1 Table 2 Table 3 IDPerson IDRelation IDWorkPlace IDPerson IDWorkPlace What I would like to know, is how can I get all the IDPerson that are not in the Table 2 ....:omg: This is not the real name of tables and fields but believe me, it must be like this. :rolleyes: I am a newbie and maybe not but who cares :eek:

            O Offline
            O Offline
            Om Prakash Pant
            wrote on last edited by
            #5

            You can use 'not in' in query : select * from table1 where idperson not in (select idperson from table2) Om Prakash

            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