帮助SQL查询 - 根据条件选择连接表。 [英] Help with SQL query – select table for join based on a condition.

查看:356
本文介绍了帮助SQL查询 - 根据条件选择连接表。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

,

I have 2 tables TableA and TableB that we use for reporting purposes. We join these tables with other tables & select the FundName column from these.
TableA has some funds that are exclusive to TableA only (i.e. they are not present in TableB)
Also, TableB has some funds that are exclusive to TableB only (i.e. they are not present in TableA)
Finally, there are some funds that are common in both TableA as well as TableB.
I need a join query that first looks for the funds in TableA. If the corresponding Fund does not exist in TableA, then we join the earlier tables in the query with TableB.





我尝试过:



我尝试过使用EXCEPT运算符但它似乎不起作用。



What I have tried:

I have tried using EXCEPT operator but it does not seem to work.

y help will be very much appreciated.

Thanks,
Aakar.

推荐答案

解决问题的线索在于< a href =http://www.codeproject.com/Articles/33052/Visual-Representation-of-SQL-Joins> SQL连接的可视化表示 [ ^ ]
The clue to solving your problem lies in here Visual Representation of SQL Joins[^]


这篇关于帮助SQL查询 - 根据条件选择连接表。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆