Pat Pat - 7 months ago 9
SQL Question

SQl query across 2 tables with conditional

Using the MYOB database I want to query across two tables.

I have the following inner join occuring and it's linked between the ShippingMethodID.

INNER JOIN ShippingMethods ON Sales.ShippingMethodID = ShippingMethods.ShippingMethodID


There is a field I want to use in the ShippingMethods table called ShippingMethod which has string values for the actual shipping method.

Inside my WHERE section I want to test for
ShippingsMethods.ShippingMethod = Post
, for example. But my sales table, I only have the ID to go by, and I'm never certain of the index number.

How might I Run a WHERE statement that links the two tables to a required value?

Answer

Could be you shoudl add the condition tho the join

INNERJOIN ShippingMethods ON (Sales.ShippingMethodID = ShippingMethods.ShippingMethodID  
        AND ShippingsMethods.ShippingMethod = 'Post')