Mysql与Oracle的删除修改语法差异示例

一、修改

        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)

二、删除

        Mysql:

示例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)

上一篇:20210924


下一篇:数据库查询某个字段重复1次或多次的数据行(查询语句)