MySQL Forums
Forum List  »  Newbie

Re: Simple JOIN?
Posted by: Peter Brawley
Date: December 18, 2021 02:44PM

You could write ...

update xyz
join abc using(cust_id)
set xyz.cust_id=abc.cust_id
where abc.cust_id is not null;

... but it'd be entirely redundant and therefore bad practice, you need just one copy of the address unless you are tracking date-defined addresses, which the schema you show doesn't do.

So if you wish to report customer addresses for orders, just write ...

select xyz.cust_id, xyz.product, xyz.price, abc.address
from xyz
join abc using(cust_id)
order by cust_id;



Edited 1 time(s). Last edit at 12/22/2021 11:48PM by Peter Brawley.

Options: ReplyQuote


Subject
Written By
Posted
December 18, 2021 12:32PM
Re: Simple JOIN?
December 18, 2021 02:44PM


Sorry, only registered users may post in this forum.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.