如何对一个数据转发器使用两个或多个查询? [英] How to use two or more queries for one data repeter?

查看:108
本文介绍了如何对一个数据转发器使用两个或多个查询?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个查询要从表格1中访问前5个数据



i have a query to to access first 5 data form the table1

"SELECT * FROM [table1] WHERE [u_id] > (SELECT MAX([u_id]) - 5 FROM [table1]) order by u_id desc"





和第二个查询来计算问题的答案数。







and second query to count the number of answer for a question.


SELECT  COUNT(*) as count FROM answer where fk_u_id=4







现在我想将两个查询用于数据转发器。怎么可能

我们可以通过加入来做,如果是的请如何



我尝试过: < br $>


SELECT * FROM [用户] WHERE [u_id]> (SELECT MAX([u_id]) - 5 FROM [users])按u_id desc命令





SELECT COUNT(*)as count FROM answer其中fk_u_id = 4




and now i want to use both queries for a data repeter. how its possible
can we do it by join if yes how please

What I have tried:

SELECT * FROM [users] WHERE [u_id] > (SELECT MAX([u_id]) - 5 FROM [users]) order by u_id desc


SELECT COUNT(*) as count FROM answer where fk_u_id=4

推荐答案

如果这是一个asp:Repeater那么你最好一次只执行一个查询,把结果放在第一个在转发器项目中,并调用第二个转发器页脚。



如果这些选择在SP中,你不能独立执行它们那么你'我需要将它们作为多个结果集处理,你如何做到这取决于你正在使用的数据访问技术。
If this is an asp:Repeater then you're best to just execute the queries one at a time, put the results of the first one in the repeater items and call the second one for the repeater footer.

If these selects are in an SP and you can't execute them independently then you'll need to process them as a multiple resultset, and how you do that depends on what data access technology you're using.


这篇关于如何对一个数据转发器使用两个或多个查询?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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