asp sql数据库 如何合并同一表中 不同查询条件产生的 结果合并成一个记录集?
如select*froma_companywherejingp='1'select*froma_companywherehot='1'select*froma_compa...
如 select * from a_company where jingp = '1'
select * from a_company where hot = '1'
select * from a_company where hy = '1'
将以上合并成一个记录集,
我用sql= "select * from (select * from a_company where jingp = '1' union select * from a_company where hot = '1' union select * from a_company where hy = '1'
)" 没有用啊!!这样做的主要是为了实现将VIP排在最前面,然后是推荐的,然后是普通的 展开
select * from a_company where hot = '1'
select * from a_company where hy = '1'
将以上合并成一个记录集,
我用sql= "select * from (select * from a_company where jingp = '1' union select * from a_company where hot = '1' union select * from a_company where hy = '1'
)" 没有用啊!!这样做的主要是为了实现将VIP排在最前面,然后是推荐的,然后是普通的 展开
4个回答
展开全部
what you can do is using With, example,
with myThreeTableUnion (your columns are here)
as
(
your union here match the above columns
)
select ...
from myThreeTable union
order by ...
with myThreeTableUnion (your columns are here)
as
(
your union here match the above columns
)
select ...
from myThreeTable union
order by ...
追问
您能说清楚点吗?是什么意思?
追答
what is your sql verson? does it have WITH statement?
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
用order by hot desc
或用order by hy asc
排序吧
或用order by hy asc
排序吧
追问
关键是我是三种不同条件查出来的进行排序啊,用你的方法当只有两种条件查询时是可以的。关键是三种或是更多的四种!!谢谢
追答
我给你的是思路,,,你可以用表单get的方法,,,获取不同的条件查询,,,,,,
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
1、ql= "select * from (select * from a_company where jingp = '1' union select * from a_company where hot = '1' union select * from a_company where hy = '1'的数据插入临时表中
2、select * from 临时表 order by ...
2、select * from 临时表 order by ...
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询