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 Joins Help

SQL Joins Help

Scheduled Pinned Locked Moved Database
questionphpdatabasecomtools
4 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.
  • J Offline
    J Offline
    Jammer 0
    wrote on last edited by
    #1

    Hi All, If I have two tables both with a varchar(50) field called Name how do i get just James2 to return? Table 1 has one record 'James' and Table 2 has two records 'James' & 'James2'. I've tried all the JOINS but I just cannot get this to work: SELECT dbo.Table_2.Name FROM dbo.Table_2 RIGHT JOIN dbo.Table_1 ON dbo.Table_1.Name = dbo.Table_2.Name I'm such a SQL Dunce!! Help! Cheers,

    Jammer My Blog | Articles | DMon | SampleSort

    S M 2 Replies Last reply
    0
    • J Jammer 0

      Hi All, If I have two tables both with a varchar(50) field called Name how do i get just James2 to return? Table 1 has one record 'James' and Table 2 has two records 'James' & 'James2'. I've tried all the JOINS but I just cannot get this to work: SELECT dbo.Table_2.Name FROM dbo.Table_2 RIGHT JOIN dbo.Table_1 ON dbo.Table_1.Name = dbo.Table_2.Name I'm such a SQL Dunce!! Help! Cheers,

      Jammer My Blog | Articles | DMon | SampleSort

      S Offline
      S Offline
      scottgp
      wrote on last edited by
      #2

      add: Where dbo.Table_2.Name = 'James2' ? Scott

      1 Reply Last reply
      0
      • J Jammer 0

        Hi All, If I have two tables both with a varchar(50) field called Name how do i get just James2 to return? Table 1 has one record 'James' and Table 2 has two records 'James' & 'James2'. I've tried all the JOINS but I just cannot get this to work: SELECT dbo.Table_2.Name FROM dbo.Table_2 RIGHT JOIN dbo.Table_1 ON dbo.Table_1.Name = dbo.Table_2.Name I'm such a SQL Dunce!! Help! Cheers,

        Jammer My Blog | Articles | DMon | SampleSort

        M Offline
        M Offline
        Mycroft Holmes
        wrote on last edited by
        #3

        Do a left join on the name and filter where table2.name is null

        Select *
        From Table1 T
        Left Join Table2 T2 on T.Name = T2.Name
        Where T2.Name is NULL

        Never underestimate the power of human stupidity RAH

        J 1 Reply Last reply
        0
        • M Mycroft Holmes

          Do a left join on the name and filter where table2.name is null

          Select *
          From Table1 T
          Left Join Table2 T2 on T.Name = T2.Name
          Where T2.Name is NULL

          Never underestimate the power of human stupidity RAH

          J Offline
          J Offline
          Jammer 0
          wrote on last edited by
          #4

          Thanks Mycroft ...

          Jammer My Blog | Articles | DMon | SampleSort

          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