请帮助我建立用于获取数据的sql查询 [英] Please help me to built sql query for fetching data
问题描述
我有两个表currentmember [当前现有用户的记录]和memberhistory
[前用户]
它们都保持单独的记录
这两个表的结构相同,并且
mem_id uniqueidetifier,
成员名称varchar(200),
DOB DATETIME,
地址varchar(500)
请注意:
memberhistory表的内容记录了用户离开组织后移至memberhistory表的情况
并从currentmember表中删除
现在,无论当前表还是历史表,我都希望从这两个表中获取记录
通过DOB DESC进行单个查询
请帮助
非常感谢..
I have two table currentmember[record of current existing users] and memberhistory
[ex-users]
they both maintain seprate records
Both tables have same structure and
mem_id uniqueidetifier,
membername varchar(200),
DOB DATETIME,
Address varchar(500)
Please Note:
memberhistory table content records when user leave the orgaization it moved to memberhistory table
and deleted from currentmember table
NOW i want to fetch records from both table irrespective of current and history table
with single query according DOB DESC
PLEASE HELP
Many thanks..
推荐答案
您可以使用UNION
运算符,例如:
You can use aUNION
operator, like :
select * from (
select * from [ex-users]
union
select * from [memberhistory]
) as t order by DOB_DATETIME
这篇关于请帮助我建立用于获取数据的sql查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!