Join query return multiple results

  • I have a following query where when I ran this, it will return me a value that duplicate from secondary join table.

    at any values I have in secondary table, it will loop the result for each rows of them, here is my data from secondary table

    domainaccountnameCreated

    SAMPAKBRTZAKI2012-09-17

    SAMEASBRTZAKI2010-01-15

    SAMUSABRTZAKI2014-10-12

    SAMS BRTZAKI2012-09-20

    and the query below will return each row above 4 duplicate rows

    select top 100 * from PWDLASTSET PWD

    join USERSREATED UCR

    on PWD.[AccountName]=UCRAccountName

    where signtype='B' and [accountname]='BRTZAKI'

  • Yes, if you have multiple matches in the second table then you'll get one row for each in your result set. Now, what results are you expecting to see?

    John

  • I'm with John, that makes perfect sense based on the data you're showing.

    Side note, get in the habit of identifying the owner of every column in your queries, not just the ones that may cause you problems. It makes the code much easier to read later.

    "The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
    - Theodore Roosevelt

    Author of:
    SQL Server Execution Plans
    SQL Server Query Performance Tuning

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply