一、修改
MysqL: 两个表关联
示例1:
UPDATE IOV_CAR_INFO TT
JOIN IOV_CAR_PARTS C ON TT.VIN = C.FRAMENUM
SET TT.EXTRACT = 0
WHERE
TT.EXTRACT = 2
示例2:
UPDATE `test_user` u
INNER JOIN
(SELECT u.id,d.city_id FROM test_department d INNER JOIN `test_user` u on u.dept_id=d.id WHERE u.enabled=0 and d.enabled=0) t
on t.id=u.id
SET u.city_id=t.city_id
WHERE
u.enabled=0
and u.dept_id is not null;
Oracle:
示例1:
UPDATE IOV_CAR_INFO TT
SET TT.EXTRACT = 0
WHERE
TT.ID IN (
SELECT
T.ID
FROM
IOV_CAR_INFO T
JOIN IOV_CAR_PARTS C ON T.VIN = C.FRAMENUM
WHERE
T.EXTRACT = 2)
二、删除
示例1:
DELETE T
FROM
IOV_LIFECYCLE T
LEFT JOIN IOV_CAR C ON T.VIN = C.VIN
LEFT JOIN IOV_DEVICE D ON D.IOV_CAR_ID = C.ID
WHERE
D.ID IS NULL
Oracle:
示例1:
DELETE
FROM
IOV_LIFECYCLE TT
WHERE
TT.ID IN (
SELECT
T.ID
FROM
IOV_LIFECYCLE T
LEFT JOIN IOV_CAR C ON T.VIN = C.VIN
LEFT JOIN IOV_DEVICE D ON D.IOV_CAR_ID = C.ID
WHERE
D.ID IS NULL)
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。