简体   繁体   English

查询以更新HeidiSql中表中的外键行

[英]Query to update a foreign key row in a table in HeidiSql

In my heidiSql data base,I have ringee user table ..In that table i have ringee user id,user name,mobile number,imei code,is delete...Here ringee user id is primary key .I have another table called event table ... Here i have event id,ringee user id,event name,place...Here event id is Primary key and `ringee user id is foreign key... 在我的heidiSql数据库中,我有ringee用户表 ..在该表中,我有ringee用户ID,用户名,手机号码,imei代码,正在删除...这里ringee用户ID是主键 。我还有另一个表称为event表 ...在这里,我有事件ID,参与者用户ID,事件名称,地点...这里事件ID是主键,`用户用户ID是外键...

What is my need is ,i need to update the ringee user id(foreign key) in event table when the ringee user id for that paricular id got changed... How to do this.What is query for that ..Please help me to find... 我需要的是,当该特定ID的特定用户的ID被更改时,我需要在事件表中更新该特定用户的ID(外键)...如何执行此操作。这是什么查询..请帮助我找到...

This is my event table query 这是我的事件表查询

CREATE TABLE `event` (
    `EVENT_ID` BIGINT(20) NOT NULL,
    `RINGEE_USER_ID` BIGINT(20) NOT NULL,
    `TEXT` VARCHAR(45) NOT NULL,
    `PLACE` VARCHAR(45) NOT NULL,
    `EVENT_DATE` DATETIME NOT NULL,
    `START_TIME` VARCHAR(10) NULL DEFAULT NULL,
    `END_TIME` VARCHAR(10) NULL DEFAULT NULL,
    `IS_DELETE` TINYINT(1) NULL DEFAULT '0',
    `CREATED_DTTM` TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP,
    `MODIFIED_DTTM` TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
    PRIMARY KEY (`EVENT_ID`),
    INDEX `EVENT_ID` (`EVENT_ID`),
    INDEX `FK_EVENT_RINGEE_USER_ID` (`RINGEE_USER_ID`),
    CONSTRAINT `FK_EVENT_RINGEE_USER_ID` FOREIGN KEY (`RINGEE_USER_ID`) REFERENCES `ringee_user` (`RINGEE_USER_ID`) ON UPDATE NO ACTION ON DELETE NO ACTION
)
COLLATE='utf8_general_ci'
ENGINE=InnoDB;

Here i need to update the ringee user id.. 在这里,我需要更新铃声用户ID。

try this CASCADE 试试这个CASCADE

(`RINGEE_USER_ID`) ON UPDATE CASCADE  ON DELETE NO ACTION

ex. 例如

CREATE TABLE GROUP(
     group_id INT NOT NULL,
     group_name VARCHAR(50),
     PRIMARY KEY (group_id)
) ENGINE=INNODB;

CREATE TABLE USER (
     user_id INT, 
     user_name VARCHAR(50), 
     group_id INT,
     FOREIGN KEY (group_id) REFERENCES GROUP (group_id) ON UPDATE CASCADE ON DELETE NO ACTION
) ENGINE=INNODB;

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在UPDATE上更新同一表的不同行的外键 - Update foreign key of different row of the same table on UPDATE 表错误:1452无法添加或更新子行:外键? - Table ERROR:1452 Cannot add or update a child row: a foreign key? 使用查询更新对象外键 - Update object foreign key with query 使用外键更新值和表 - Update a value and a table with a foreign key 从表中删除行:“无法删除或更新父行:外键约束失败”是外键问题或CASCADE会完成这项工作吗? - Delete row from table:“Cannot delete or update a parent row:a foreign key constraint fails” is that a FOREIGN KEY problemm or CASCADE will do the job? 使用UPDATE查询(HeidiSQL)将单元格的NULL值更改为-1 - Changing NULL value of cells to -1 with UPDATE query (HeidiSQL) 添加外键约束时无法更新子表:错误:无法添加或更新子行:外键约束失败 - unable to update a child table when a foreign key constraint is added: error :Cannot add or update a child row: a foreign key constraint fails php(数组)-> mysql(带有外键的多行)更新表中特定行,其中id和行号不同 - php (array)-> mysql (multiple rows with a foreign key) Update specific row in table where id and row number varies 如何更新 NULL 外键并在引用相同键的另一个表中创建新行? - How to update a NULL foreign key and create a new row within another table referencing the same key? 使用UPDATE查询的UPDATE外键 - UPDATE foreign key using UPDATE query
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM