Problems with retrieving all the records from tables

  • Hi there

    I am using the following statement in an attempt to retrieve details of all people who have the subcodes as shown. However, only one person per subcode is getting retrieved. So, rather than having for example, 500 people with AFF and 20 with GAF, I am only getting back 1 of each.

    Could someone please tell me what I'm doing wrong in my statement?

    select ContactID, Forenames, Surname, SubscriptionTypes.SubCode

    from Contacts

    INNER JOIN SubscriptionTypes

    ON SubscriptionTypes.ID=Contacts.ContactID

    WHERE Subcode IN ('AFF','AFF2','AFF3','AFFLGDP','AFFOS','GAF','GAFFM','GAFFMOS','GAFLGDP','GAFOS','RAF')

    Many thanks

    Jon

  • The query looks valid.

    Please provide table def and sample data together with your expected result based on the sample data provided.

    Otherwise we'd just be guessing here...



    Lutz
    A pessimist is an optimist with experience.

    How to get fast answers to your question[/url]
    How to post performance related questions[/url]
    Links for Tally Table [/url] , Cross Tabs [/url] and Dynamic Cross Tabs [/url], Delimited Split Function[/url]

  • Hi Lutz

    Thank you for your reply. I have re-looked at the tables in my query and it seems as though I was missing a table which held all the relevant information.

    So, on this occasion we can put it down to "newbie error".

    Many thanks for your time.

    Best wishes

    Jon

  • :w00t:

    SSMS Expert

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

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