MySQL Forums
Forum List  »  Newbie

Re: Lookup multiple tables
Posted by: Peter Brawley
Date: May 24, 2021 10:47AM

Yes, you didn't mention in your problem description that you meant to do this in a Trigger---we can't invoke Insert or Update on the Table for which an Insert or Update Trigger is defined.

Nor can we SET a new.value in an After Insert Trigger; it has to be Before Insert (best to read the manual page for a functionality before trying to use it).

Nor do your column names & field names match the problem description.

Assuming the column names you started with, in such a Trigger you can write ...

set NEW.name = (
  select p.name
  from person p  
  join owner  o on p.id_person=o.id_person
  join card   o on c.id_card=o.id_card
  where c.cardnumber = NEW.cardnumber
);

Options: ReplyQuote


Subject
Written By
Posted
May 22, 2021 02:34AM
Re: Lookup multiple tables
May 24, 2021 10:47AM


Sorry, you can't reply to this topic. It has been closed.

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.