Hi
We have table sin our sql which are customer, orderheader, customeraddress and journey header
I am trying to get a view that shows me the
Name of the customer
Address lines for the delivery by a particular journey number.
I am getting the right number of results back from the query but incorrect address information. it appears to be taking the customer ordering post codes form the oderheader and not the customeraddress post code (customer address is basically a delivery address).
I ma for example getting the postcode OX17 3SN where on the order and journey header it is being delivered to OX16 4TB
I have tried different joins but still get the same postcodes. Could someone advise what I need to do please to get the right result. Thanks
SELECT dbo.Customer.CustomerCode, dbo.Customer.Name, dbo.CustomerAddress.Address1, dbo.CustomerAddress.Address2, dbo.CustomerAddress.Address3,
dbo.CustomerAddress.City, dbo.CustomerAddress.County, dbo.CustomerAddress.PostCode, dbo.JourneyHeader.JourneyNumber
FROM dbrderHeader INNER JOIN
dbo.CustomerAddress ON dbrderHeader.DeliveryAddressID = dbo.CustomerAddress.CustomerAddressID INNER JOIN
dbo.JourneyHeader ON dbrderHeader.JourneyID = dbo.JourneyHeader.JourneyID INNER JOIN
dbo.Customer ON dbrderHeader.CustomerID = dbo.Customer.CustomerID
WHERE (dbo.JourneyHeader.JourneyNumber = 66183)
We have table sin our sql which are customer, orderheader, customeraddress and journey header
I am trying to get a view that shows me the
Name of the customer
Address lines for the delivery by a particular journey number.
I am getting the right number of results back from the query but incorrect address information. it appears to be taking the customer ordering post codes form the oderheader and not the customeraddress post code (customer address is basically a delivery address).
I ma for example getting the postcode OX17 3SN where on the order and journey header it is being delivered to OX16 4TB
I have tried different joins but still get the same postcodes. Could someone advise what I need to do please to get the right result. Thanks
SELECT dbo.Customer.CustomerCode, dbo.Customer.Name, dbo.CustomerAddress.Address1, dbo.CustomerAddress.Address2, dbo.CustomerAddress.Address3,
dbo.CustomerAddress.City, dbo.CustomerAddress.County, dbo.CustomerAddress.PostCode, dbo.JourneyHeader.JourneyNumber
FROM dbrderHeader INNER JOIN
dbo.CustomerAddress ON dbrderHeader.DeliveryAddressID = dbo.CustomerAddress.CustomerAddressID INNER JOIN
dbo.JourneyHeader ON dbrderHeader.JourneyID = dbo.JourneyHeader.JourneyID INNER JOIN
dbo.Customer ON dbrderHeader.CustomerID = dbo.Customer.CustomerID
WHERE (dbo.JourneyHeader.JourneyNumber = 66183)