Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use the result in the first sql statement as the parameter value of the second sql

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

How to take the result in the first sql statement as the parameter value of the second sql, I believe that many inexperienced people do not know what to do about it. Therefore, this paper summarizes the causes and solutions of the problem. Through this article, I hope you can solve this problem.

Demand:

Report multiple datasets, and the parameters of the second dataset need to refer to the result set of the first dataset as parameter values to filter the data.

The solution is as follows:

Because the datasets of the report are all calculated at the same time, the result set of ds1 cannot be directly used as the parameter value of ds2.

So the way of using dynamic parameters, using query () function to solve.

Example: filter the data from the order table in the demo database table by the owner's name, and then query the order details of the corresponding order ID.

Procedure:

1. Create a new dataset, ds1, and set it as shown below. And add the parameter arg1 to the report-parameters.

two. Create a new ds2 dataset

The sql statement is: select * from order details where order ID in (${m})

Description: 1. Because ${m} is written as a dynamic parameter, there is no need to set the parameters of the dataset.

two。 Because the data filtered by ds1 may not be the same, we use the string group of in to filter the data of ds2.

3. Set dynamic parameters.

The judgment of writing if is for a default parameter value of the ds2 dataset. Otherwise, an error will be reported when the parameter is empty.

Then perform a report preview to test the effect.

After reading the above, have you learned how to use the result in the first sql statement as the parameter value of the second sql? If you want to learn more skills or want to know more about it, you are welcome to follow the industry information channel, thank you for reading!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report