用openquery进行分布式查询和简化

帮我一下,我如何让下面的语句再简单呢?b和d是同一个表!
select a.*,b.description,d.description from
openquery(safelinked,'select * from asco.time_period') a,
openquery(safelinked,'select * from asco.days_lookup') b ,
openquery(safelinked,'select * from asco.days_lookup') d
where b.id=a.id
and d.id=a.id

---------------------------------------------------------------

select * from
openquery(safelinked,'select a.*,b.description,d.description from asco.time_period a,asco.days_lookup b,asco.days_lookup d
where b.days_id=a.start_day and d.days_id=a.stop_day') x
order by tp_id

Published At
Categories with 数据库类
Tagged with
comments powered by Disqus