我必须根据可以为空的值选择相应的列以进行联接。详细地:
SELECT shoporders.orderid, shopaddresses.companyname, shopaddresses.firstname, shopaddresses.lastname, shopaddresses.address1, FROM shoporders INNER JOIN shopaddresses ON shoporders.InvoiceAddressId = shopaddresses.addressid where orderid = 110 order by shoporders.createddate desc
如果shoporders.InvoiceAddressId为null,那么我必须使用shoporders.DeliveryAddressId
有什么线索吗?
提前致谢
ON coalesce(shoporders.InvoiceAddressId, shoporders.DeliveryAddressId) = shopaddresses.addressid