今天也要学习呐 2022-03-01 20:10 采纳率: 68.2%
浏览 58
已结题

怎么从一张表中剔除数据

问题遇到的现象和发生背景

比如想从A表中剔除B表里某字段为1的数据

问题相关代码,请勿粘贴截图
create table if not exists testA(
user_id string,
user_name,
level string
);

create table if not exists testB(
user_id string,
tag int
);
--testA和testB两张表可以通过user_id相关联,现在希望两表关联,testB中tag字段为1的,从testA表里剔除出去
运行结果及报错内容
我的解答思路和尝试过的方法
我想要达到的结果

testA和testB两张表可以通过user_id相关联,现在希望两表关联,testB中tag字段为1的,从testA表里剔除出去

  • 写回答

3条回答 默认 最新

  • £漫步 云端彡 2022-03-01 20:36
    关注

    DELETE FROM testa WHERE user_id IN (SELECT user_id FROM testb WHERE tag=1);

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

问题事件

  • 系统已结题 3月10日
  • 已采纳回答 3月2日
  • 创建了问题 3月1日