在sql中保留通用值并获得休息值 [英] to leave common values and get rest values in sql
本文介绍了在sql中保留通用值并获得休息值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在sql中有两个表.如果该值已经在两个表的两个列中.我想保留公共值并获得rest值.通过使用并集我可以获得正确的结果,但是如果我想从一个中获得两个列表查询抛出异常.请帮帮我.
I have two table in sql .If the value is already in both columns in both table .I want to leave common value and get rest values.by using union i get proper result but if i want to get two coumns from one table the query throw an exception.pls help me.
select Top(10) (User_Id) as id,type from New_Regs union select User_ID as type from UserIDMapping where Table_Ref ='New_Regs'
上面的查询类型在useridmapping表中不可用.但是我需要new_regs
in the above query type is not avaliable in useridmapping table.but i need both columns from new_regs
推荐答案
的两列,我几乎不明白您要做什么.您可以尝试:
I hardly understand what you try to do. Could you try:
select Top(10) (User_Id) as id, type
FROM New_Regs
UNION
select User_ID as id, '' as type
FROM UserIDMapping
where Table_Ref ='New_Regs'
这篇关于在sql中保留通用值并获得休息值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文