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. The multipart identifier could not be bound

The multipart identifier could not be bound

Scheduled Pinned Locked Moved Database
databasehelptutorial
4 Posts 2 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
    JacquesDP
    wrote on last edited by
    #1

    Hi guys, I have the following query, example Select a.id, b.description from table1 a left join (select top 1 c.id, c.description from tableb c where c.id = a.id) as b on b.id = a.id The reason I do this is because tableb could have multiple duplicates of c.id and I want it to only do the select on one specific id from the table1. But I get the error because a.id is not within the select statement of tableb. Is there any way that I can do this, if I remove the where clause in the tableb select statement it returns duplicate values on the description. Thanks in advance

    No matter how long he who laughs last laughs, he who laughs first has a head start!

    B 1 Reply Last reply
    0
    • J JacquesDP

      Hi guys, I have the following query, example Select a.id, b.description from table1 a left join (select top 1 c.id, c.description from tableb c where c.id = a.id) as b on b.id = a.id The reason I do this is because tableb could have multiple duplicates of c.id and I want it to only do the select on one specific id from the table1. But I get the error because a.id is not within the select statement of tableb. Is there any way that I can do this, if I remove the where clause in the tableb select statement it returns duplicate values on the description. Thanks in advance

      No matter how long he who laughs last laughs, he who laughs first has a head start!

      B Offline
      B Offline
      Blue_Boy
      wrote on last edited by
      #2

      Try this Select a.id (select top 1 c.id from tableb c where c.id = a.id) , (select top 1 c.description from tableb c where c.id = a.id) from table1 a


      I Love T-SQL "Don't torture yourself,let the life to do it for you."

      J 1 Reply Last reply
      0
      • B Blue_Boy

        Try this Select a.id (select top 1 c.id from tableb c where c.id = a.id) , (select top 1 c.description from tableb c where c.id = a.id) from table1 a


        I Love T-SQL "Don't torture yourself,let the life to do it for you."

        J Offline
        J Offline
        JacquesDP
        wrote on last edited by
        #3

        Works, Thanks

        No matter how long he who laughs last laughs, he who laughs first has a head start!

        B 1 Reply Last reply
        0
        • J JacquesDP

          Works, Thanks

          No matter how long he who laughs last laughs, he who laughs first has a head start!

          B Offline
          B Offline
          Blue_Boy
          wrote on last edited by
          #4

          No problem,I am glad that worked for you.


          I Love T-SQL "Don't torture yourself,let the life to do it for you."

          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