sql-server - 有没有办法加入 2 个表并验证它们拥有的数据
解决方案
你肯定需要重新审视你的桌子设计。
我不是很清楚你在找什么,但我觉得你在派生表中寻找一个或多个值为空的整体。对于这种情况,您可以编写如下查询。
select distinct mt.mainid from maintable mt
inner join derivedtable m on mt.mainid=m.id and m.name='MainId'
inner join derivedtable u on mt.mainid=u.id and u.name='UserId'
inner join derivedtable r on mt.mainid=r.id and r.name='RoleId'
where (m.value is null or u.value is null or r.value is null)
推荐阅读
- c# - Angular 9 前端和 ASP.NET Core 3.1 API 后端中的防伪令牌
- python - Tensorflow:使用自定义渐变制作自定义 Conv2d 层
- sql - 如何修复 SQLite NTILE 语句中的语法错误?
- forms - 用vuex提交后清除表单
- css - 使用 display flex 使所有存储桶具有相同的高度
- php - 如何在回显消息显示之前在 php 中设置超时?
- flutter - 如何以颤振形式添加特定的域验证器?
- javascript - 在 React 中使用百分比创建动态仪表
- node.js - 如何在 Adonis Js 中查询数据透视表
- php - PHP 函数是否在执行以下代码之前完成运行?