List:General Discussion« Previous MessageNext Message »
From:Victoria Reznichenko Date:September 10 2003 9:39pm
Subject:Re: Foreign key update?
View as plain text  
"Daevid Vincent" <daevid@stripped> wrote:
> I see there is a way to DELETE or NULL a cascade, but is there a way to
> UPDATE?

ON UPDATE CASCADE, ON UPDATE SET NULL.

Look at:
	http://www.mysql.com/doc/en/InnoDB_foreign_key_constraints.html

> 
> Here's what I mean. Given these rough table schemas. I'd like to be able to
> UPDATE the company_code in the company_table, and have it update the same
> rep_company_code in the rep_table.  Ie. So a company has a certain code,
> then we change it. I want all the reps to get their codes updated too
> automagically... Is this possible now or in a future mySQL version?
> 
> CREATE TABLE company_table (
>  company_id mediumint(8) unsigned NOT NULL auto_increment,
>  company_name varchar(255) NOT NULL default '',
>  company_code varchar(15) NOT NULL default '',
>  company_referal_code varchar(15) NOT NULL default '',
>  company_phone varchar(20) NOT NULL default '',
>  company_fax varchar(20) NOT NULL default '',
>  company_url varchar(50) NOT NULL default '',
>  company_address1 varchar(70) NOT NULL default '',
>  company_address2 varchar(70) NOT NULL default '',
>  company_city varchar(50) NOT NULL default '',
>  company_state varchar(50) NOT NULL default '',
>  company_zip varchar(50) NOT NULL default '',
> ) TYPE=InnoDB;
> 
> 
> CREATE TABLE rep_table (
>  rep_id smallint(5) unsigned NOT NULL auto_increment,
>  rep_login varchar(15) NOT NULL default '',
>  rep_password varchar(15) NOT NULL default '',
>  rep_company_code varchar(15) NOT NULL default '',
>  rep_fname varchar(20) NOT NULL default '',
>  rep_lname varchar(20) NOT NULL default '',
>  rep_title varchar(50) NOT NULL default '',
> ) TYPE=InnoDB;
> 
> 


-- 
For technical support contracts, goto https://order.mysql.com/?ref=ensita
This email is sponsored by Ensita.net http://www.ensita.net/
   __  ___     ___ ____  __
  /  |/  /_ __/ __/ __ \/ /    Victoria Reznichenko
 / /|_/ / // /\ \/ /_/ / /__   Victoria.Reznichenko@stripped
/_/  /_/\_, /___/\___\_\___/   MySQL AB / Ensita.net
       <___/   www.mysql.com




Thread
Foreign key update?Daevid Vincent10 Sep
  • Re: Foreign key update?Victoria Reznichenko10 Sep
    • RE: Foreign key update?Daevid Vincent11 Sep
      • RE: Foreign key update?Daevid Vincent11 Sep
      • Re: Foreign key update?Victoria Reznichenko11 Sep
        • RE: Foreign key update and Error :: 1217Daevid Vincent11 Sep
RE: Foreign key update?Dan Greene10 Sep
Re: Foreign key update and Error :: 1217Heikki Tuuri11 Sep
  • RE: Foreign key update and Error :: 1217 with v4.0.15Daevid Vincent12 Sep
    • Re: Foreign key update and Error :: 1217 with v4.0.15Heikki Tuuri12 Sep
      • RE: Foreign key update and Error :: 1217 with v4.0.15 [SOLVED]Daevid Vincent12 Sep