运行查询只有一次

2023-09-06 10:58:18 作者:对你微笑,纯属可笑

我有一个包含2个按钮的应用程序。

I have an application which contains 2 buttons.

按钮1此查询给出结果:

Button 1 gives the result by this query:

select * from tbl1;

按钮2这个疑问给出结果:

Button 2 gives the result by this queries:

select * from tbl1;
select * from tbl2;

所以,发生了什么事是,我要运行 SELECT *从TBL 1 两次,一次扣1,并再次为按钮2。

So what's happening is that I have to run select * from tbl1 twice, Once for button 1 and once again for button 2.

是否有可能一次运行这两个查询按钮1被点击时,但只显示结果从 TBL 1 ,然后显示来自结果tbl2的按钮2被点击?

Is it possible to run both queries once when button 1 is clicked, but only show the results from tbl1, and then show the results from tbl2 when button 2 is clicked?

推荐答案

是的,缓存结果。它存储到一个变量(一个的集合的像列表),然后用它来显示结果,而不是的重新评估的查询。

Yes, cache the result. Store it into a variable (a collection like List) then use it to display result instead of re-evaluating the query.

相关推荐