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 make fuzzy query in big data report

2025-02-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

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

The content of this article mainly focuses on how to do fuzzy query on big data report. The content of the article is clear and clear. It is very suitable for beginners to learn and is worth reading. Interested friends can follow the editor to read together. I hope you can get something through this article!

In the data query system, we often encounter accurate query and fuzzy query. We know that for relational databases, precise queries can filter the corresponding data directly using "where field = parameter value" in sql, while to implement fuzzy queries, we use the form of like. So, how to use like to implement fuzzy query to filter data in the report?

Next, let's combine the customer table in the hsql database to do an example of a fuzzy query.

For example, in the drop-down box, all contacts with the word "king" in their names are displayed through a fuzzy query, and a precise query is made when the user selects it. And the result list shows all the data for the first time. As shown in the following figure:

This is a common and experienced reporting requirement, how can we achieve it?

The operation is very simple. Let's do it together.

Step 1: connect the data source

First connect to our own demo database, and don't forget to start the sample database first.

Step 2: create a new dataset

1) Sql syntax is: SELECT * FROM customer WHERE customer. Contact name like? Or? Is null (because we want to display all the data in the results list before the first query, so we need to write or? Is null, that is, query all data when the parameter is empty. )

2) set the parameters of the dataset. The format is "%" + parameter name + "%". (note: we have written two question marks for the same field "contact name", so we need to write two identical parameters. )

As shown in the following figure:

Step 3: design the report and add the same parameters as the dataset name to the report-parameters:

Step 4: save the report and set the report name to test.rpx

Step 5: create a parameter template

1) create a new dataset and just take out the contact name field in the customer table.

2) set the cell editing style and web variable name for B1 cell

Step 6: save the parameter template and set the report name to test_arg.rpx

(note: the name of the parameter template should be the same as the name of the main report, and add _ arg. Then save the parameter template in the same directory as the main report)

Step 7: start tomcat and publish the report.

The display effect is as follows:

In an experiment, we enter the word "king" in the cell, and you can see that the drop-down box will show all the contacts whose names contain "king".

Click on the query to show the effect as follows:

Or, after typing "Wang", select any contact in the drop-down list and click query to filter the data.

Shh ~ ~ finally, I'll tell you a little secret. Due to database-driven problems, if there is null data in the name field of the contact to be queried, you may not find all the data when you query all the data for the first time, that is, the empty data cannot be displayed. At this point, we need to change the parameters of the data set of the fuzzy query to the following format: (the second parameter is not written by percent concatenation, and the other parameters do not need to be changed).

Thank you for your reading, I believe you have a certain understanding of the "big data report how to do fuzzy query" this problem, quickly go to practice, if you want to know more relevant knowledge points, you can pay attention to the website! The editor will continue to bring you better articles!

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