Select Query Advice

  • He Everyone. 

    I am guessing this will be a simple one for you to knock out but i can get this query to pull back the data i require. 

    So to put it simply.  I have 2 Tables.  One list called Applications lists all applications installed on lots of machines however for the sake of this example i just have a few records but bear in mind 1 machine could have around 30 entries.

    TBL_APPLICATIONS

    MACHINE_NAME      APPLICATION
    PC001                        Word
    PC001                        Excel
    PC001                        Powerpoint
    PC002                        Word
    PC002                        Winzip

    TBL_MACHINES

    MACHINE_NAME
    PC001
    PC003

    Basically I want to show all records (MACHINE_NAME and APPLICATION) from TBL_APPLICATIONS where by MACHINE_NAME in bot Tables match.  my existing query is not showing the correct number of entrys.  I am guessing my join is all screwed up. 

    This is what i have  

    select apps.MACHINE_NAME, apps.Application
    from dbo.TBL_APPLICATIONS$ as apps
       Join dbo.TBL_MACHINES$ as pcs
           ON pcs.MACHINE_NAME=apps.MACHINE_NAME

    This is not working for some reason and i have tried every join.  Can anyone assist.

  • Andrew.weckermann - Thursday, September 27, 2018 7:38 AM

    He Everyone. 

    I am guessing this will be a simple one for you to knock out but i can get this query to pull back the data i require. 

    So to put it simply.  I have 2 Tables.  One list called Applications lists all applications installed on lots of machines however for the sake of this example i just have a few records but bear in mind 1 machine could have around 30 entries.

    TBL_APPLICATIONS

    MACHINE_NAME      APPLICATION
    PC001                        Word
    PC001                        Excel
    PC001                        Powerpoint
    PC002                        Word
    PC002                        Winzip

    TBL_MACHINES

    MACHINE_NAME
    PC001
    PC003

    Basically I want to show all records (MACHINE_NAME and APPLICATION) from TBL_APPLICATIONS where by MACHINE_NAME in bot Tables match.  my existing query is not showing the correct number of entrys.  I am guessing my join is all screwed up. 

    This is what i have  

    select apps.MACHINE_NAME, apps.Application
    from dbo.TBL_APPLICATIONS$ as apps
       Join dbo.TBL_MACHINES$ as pcs
           ON pcs.MACHINE_NAME=apps.MACHINE_NAME

    This is not working for some reason and i have tried every join.  Can anyone assist.

    Too many entries, or too few?

    Your join is fine. Is MACHINE_NAME unique in table dbo.TBL_MACHINES$ ?

    Presumably you require other data from dbo.TBL_MACHINES$, otherwise your entire query could come from dbo.TBL_APPLICATIONS$.

    If you haven't even tried to resolve your issue, please don't expect the hard-working volunteers here to waste their time providing links to answers which you could easily have found yourself.

  • Apologies my mistake my data was not ordered correctly.  🙁  Thanks for confirming my query was all good though.

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

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