侧边栏壁纸
  • 累计撰写 781 篇文章
  • 累计创建 1 个标签
  • 累计收到 1 条评论
标签搜索

update

Dettan
2021-04-10 / 0 评论 / 0 点赞 / 128 阅读 / 1,109 字
温馨提示:
本文最后更新于 2022-04-28,若内容或图片失效,请留言反馈。部分素材来自网络,若不小心影响到您的利益,请联系我们删除。
/ DATA / update
UPDATE T1, T2,
[INNER JOIN | LEFT JOIN] T1 ON T1.C1 = T2. C1
SET T1.C2 = T2.C2, 
    T2.C3 = expr
WHERE condition
Update table set colume=... , colum=...

UPDATE words
JOIN all_words ON words.word = all_words.word 
SET words.meaning = all_words.meaning;
example
accent	n.口音,腔调;重音
accept	vt.vi.接受;同意
  ||
  \/
accept	vt.vi.接受;同意 | vt.vi.接受;同意

select *,count(meaning) count,group_concat(meaning,' | ') mean from e4 group by word having count(meaning)>1;

UPDATE e4 join (select *,count(meaning) count,group_concat(meaning,' | ') mean from e4 group by word having count(meaning)>1) b using(word)
SET e4.meaning = b.mean
WHERE
e4.word = e4.word;




UPDATE
	T_MAP_ICON 
SET
	FD_ASSOCIATE_ID =
	(CASE
		WHEN FD_ASSOCIATE_ID = 111 THEN 222
		WHEN FD_ASSOCIATE_ID = 222 THEN 111
	END)
WHERE
	FD_ASSOCIATE_ID = 111
	OR FD_ASSOCIATE_ID = 222;

UPDATE T_MAP_ICON SET FD_ASSOCIATE_ID ='' 
WHERE FD_ROWID IN 
	(
		SELECT FD_ROWID FROM T_MAP_ICON 
		WHERE FD_ASSOCIATE_ID = '163' AND FD_ROWID NOT IN 
			(
				SELECT i.FD_ROWID FROM T_MAP_ICON AS i 
					JOIN T_BASEINFO AS b 
					ON b.FD_FACTORYCODE = '163' AND b.FD_ROWID = i.FD_DEVICE_ID 
			)
	)
db2
join 左右的类型要一样,格式尽量严格一致
MERGE INTO T_MAP_ICON i
    USING (SELECT * FROM T_BASEINFO WHERE FD_ROWID = '149')  b 
    ON i.FD_DEVICE_ID = b.FD_ROWID
    WHEN MATCHED AND  1=1
    THEN UPDATE SET i.FD_ASSOCIATE_ID = '149';

0

评论区