0

Ok so I have three tables Customers,Invoices,and Delivery with the fields:

Customers:
CustomerID
Address
........

Orders:
OrderID
DeliveryID
.......

Delivery:
DeliveryID
DeliveryToAddress
......

So what I want to do is update my delivery table for the DeliveryToAddress for when the customers address changes within the customers tables. To get the Customers address into the delivery table it needs to pass through the order table. How do I do this as everything that I have tried does not seem to work?

3
Contributors
2
Replies
17
Views
4 Years
Discussion Span
Last Post by diafol
0
UPDATE TABLE_1 LEFT JOIN TABLE_2 ON TABLE_1.COLUMN_1= TABLE_2.COLUMN_2 
SET TABLE_1.COLUMN = EXPR WHERE TABLE_2.COLUMN2 IS NULL

This is sample query refer following link

http://dev.mysql.com/doc/refman/5.0/en/update.html

But I would suggest that you should not update address in delivery,

that will changes all address in delivery table of same customer even if delivery was made to old address. So you will loose history, that where were the consigment delivered in past.

It is good to pickup new address from customer table while taking new order and not to change address of past orders.

1

Addresses IMO should have their own table. And then you have a 'user_address' link table. That way an user can have as many addresses as they need with a flag for billing/delivery/deleted (don't show). SO the deleted ones still exist for historical purposes, they just don't show in the user's 'choose address' section.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.