Join syntax

  • hi

     

    I have two tables -tblOrders and tblOrderPayments

    tblorders contains orders and one of the columns  in it is named ProductCode. The other table, tblOrderpayments contains a column called PaymentSuccess (a bit column).

    I know there is a join involved here but I am unsure of syntax.

     

    I want to pull all the rows where the productcode is X and where they also have a Payment success of '1'

     

    Any help appreciated.

    thanks

  • Something like this?

    Select YourColumns from dbo.tblOrders O inner join dbo.tblOrderPayments OP on O.OrderID = OP.OrderID

    where ?.ProductCode = @SomeValue and OP.PaymentSuccess = 1

  • Nice to see you're properly qualifying your DB objects Remi

  • Never been bitten by this one... and I'll keep it that way .

  • If only everyone were so diligent on this sort of thing, it would save me hitting people (developers) over their heads trying to make them do it right.

    You'd be amazed at some of the excuses i've heard not to do it, the favourite one seems to be that they simply don't have the time to type the owner as well as the object itself

  • Tell them to use the freaking wizards, it types them by default and it saves 'em typing time .

Viewing 6 posts - 1 through 5 (of 5 total)

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