表二关联表一,根据表二数据来查询表一数据

ltylovem 2018-06-28 03:18:55
select companydID,Billno from master
select companydID,Billno,qwe from detail
这个时候需要查询从表,目前不能用
我现在想要根据字段qwe来查询出主表数据,但是不能用inner join
这个时候怎么查询效率会高一些
...全文
163 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
shinger126 2018-06-28
  • 打赏
  • 举报
回复
引用 3 楼 ltylovem 的回复:
[quote=引用 2 楼 shinger126 的回复:]
select companydID,Billno from master a
where exists(select 1 from detail b where b.companyid=a.companyid and b.billno=a.billno and b.qwe='XXX')
这样,话说你也是广州恒康的么。字段名这么熟悉


嗯哼[/quote]
您哪位啊,我数据技术支持部毛远新
ltylovem 2018-06-28
  • 打赏
  • 举报
回复
引用 2 楼 shinger126 的回复:
select companydID,Billno from master a
where exists(select 1 from detail b where b.companyid=a.companyid and b.billno=a.billno and b.qwe='XXX')
这样,话说你也是广州恒康的么。字段名这么熟悉


嗯哼
shinger126 2018-06-28
  • 打赏
  • 举报
回复
select companydID,Billno from master a
where exists(select 1 from detail b where b.companyid=a.companyid and b.billno=a.billno and b.qwe='XXX')
这样,话说你也是广州恒康的么。字段名这么熟悉
听雨停了 2018-06-28
  • 打赏
  • 举报
回复
没有明白你说的什么意思,最好给出测试数据,以我的理解是不是就是left/right join的意思啊

22,209

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server 疑难问题
社区管理员
  • 疑难问题社区
  • 尘觉
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧