SQL question; Can someone help me?

  • You’re given a MerchantID

    From the MerchantPayorProvider table I want those records where MerchantPayorsID is in MerchantPayors for the given MerchantID

    That query would look like,

    select *

    from merchantpayorprovider

    where merchantpayorsid in

                (select merchantpayorsid

                from merchantpayors

                where merchantid = ?)

    Then I want the PayorName from the table Payors for the given MerchantID. You can link the MerchantID to the Payor table via MerchantPayors.

    This query looks like

    select payorname

    from payor

    where PayorID in

                (select payorid

                from merchantpayors

                where merchantid = ?)

    This is what I have so far, so I want to be able to combine the two queries, if possible. Also, this does not have to be a stored proc.

    Thanks fellow DBA's OR Developers! 

     

  • select merchantpayorprovider.*, Payor.Name

    from merchantpayorprovider, Payor, Merchantpayors

    where merchantpayorprovider.merchantpayorsid=merchantpayors.merchantid

    and Payor.PayorID=merchantpayors.merchantid

  • Thanks for your help!

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

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