mysql优化 - mysql中的主从表连接后更新的问题
怪我咯
怪我咯 2017-04-17 14:23:28
[MySQL讨论组]

MySQL 5.6 Schema Setup:

CREATE TABLE ForgeRock (
    `id` INT,
    `productName` VARCHAR (7),
    `description` VARCHAR (55)
);

INSERT INTO ForgeRock (
    `id`,
    `productName`,
    `description`
)
VALUES
    (
        1,
        'OpenIDM',
        'Platform for building enterprise provisioning solutions'
    );
    
    CREATE TABLE ForgeRock_Detail (
        `detail_id` INT,
        `fr_id` INT,
        detail_description VARCHAR (55)
    );

INSERT INTO ForgeRock_Detail (
    detail_id,
    fr_id,
    detail_description
)
VALUES
    (1, 1, 'dd1'),
    (2, 1, 'dd2'),
    (3, 1, 'dd3');


Query 1:

select * from ForgeRock
left join ForgeRock_Detail
on id=fr_id

Results:

| id | productName |                                             description | detail_id | fr_id | detail_description |
|----|-------------|---------------------------------------------------------|-----------|-------|--------------------|
|  1 |     OpenIDM | Platform for building enterprise provisioning solutions |         1 |     1 |                dd1 |
|  1 |     OpenIDM | Platform for building enterprise provisioning solutions |         2 |     1 |                dd2 |
|  1 |     OpenIDM | Platform for building enterprise provisioning solutions |         3 |     1 |                dd3 |



就是一个mysql中的主从表,我现在想做的是连接后更新

UPDATE ForgeRock
LEFT JOIN ForgeRock_Detail ON id = fr_id
SET description = detail_description

现在的问题是,这条语句会不会执行三次对description的更新操作?

还有哦,这种语句有办法单步调试么?去看到底执行了几次操作。因为detail_description是不同的,如果description更新3个不同的值,应该是可以查到修改记录的。

怪我咯
怪我咯

走同样的路,发现不同的人生

全部回复(0)
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 意见反馈 讲师合作 广告合作 最新更新 English
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习
PHP中文网抖音号
发现有趣的

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号