Data query method and related device
By obtaining the query condition pool selected by the user and assembling it into SQL statements, and generating a query condition group, the problem that users cannot configure query conditions independently is solved, and efficient data query is achieved to meet users' personalized query needs.
Patent Information
- Application Number
- CN202411726832.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-28
- Publication Date
- 2025-03-21
AI Technical Summary
In the prior art, users are unable to configure query conditions independently, resulting in low data query efficiency.
Provide a data query method, by obtaining the query condition pool selected by the user, assemble it into the statistical ledger SQL statement, generate a query statement, and responding to the target query conditions selected by the user, generate a query condition group, and finally obtain the query results through the query statement based on the query condition group and the matching fields entered by the user.
Users can flexibly select target data items and target matching conditions based on query needs, realize personalized query needs, improve the efficiency of data query, and enable users to query the required results conveniently, quickly and accurately.
Smart Images

Figure CN119669257A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of big data technology, and in particular to a data query method and related devices. Background Art
[0002] With the development of information technology, statistical ledgers, as a tool for recording and summarizing statistical data, have become an important tool for data analysis for organizations such as enterprises and government departments.
[0003] At present, when data query is needed from statistical ledgers, technical personnel are usually required to construct query conditions according to needs. Users cannot independently configure query conditions to meet personalized query needs, and the efficiency of data query is low.
[0004] Therefore, how to improve the efficiency of data query becomes a problem that needs to be solved. Summary of the invention
[0005] Based on the above problems, the present application provides a data query method and related devices, which can improve the efficiency of data query.
[0006] The embodiments of the present application disclose the following technical solutions:
[0007] In a first aspect, an embodiment of the present application provides a data query method, the method comprising:
[0008] Get the query condition pool selected by the user;
[0009] Assembling the query condition pool into the statistical ledger SQL statement to generate a query statement; the query condition pool includes optional data items and optional matching conditions;
[0010] In response to a target query condition selected by a user from the query condition pool, generating a query condition group;
[0011] Based on the query condition group and a first matching field input by a user, a first query result is obtained through the query statement; the matching field is a field included in the data item.
[0012] Optionally, generating a query condition group in response to a target query condition selected by a user from the query condition pool includes:
[0013] In response to a target data item selected by a user from the selectable data items, identifying a data type of the target data item;
[0014] Determine, from the query condition pool, optional matching conditions corresponding to the data types of the respective target data items;
[0015] In response to the target matching conditions corresponding to the respective target data items selected by the user from the optional matching conditions, a query condition group is generated.
[0016] Optionally, when the data type includes text, the optional matching conditions include exact matching and fuzzy matching; when the data type includes numbers or dates, the optional matching conditions include equal to, not equal to, less than, less than or equal to, greater than, and greater than or equal to.
[0017] Optionally, before obtaining the query condition pool selected by the user, the method further includes:
[0018] Get optional data items and optional matching conditions entered by the user;
[0019] A query condition pool is generated based on the optional data items and the optional matching conditions.
[0020] Optionally, after generating a query condition group in response to a target query condition selected by a user from the query condition pool, the method further includes:
[0021] storing the query condition group as a historical query group;
[0022] Based on the target query group selected by the user from one or more historical query groups and the second matching field input by the user, a second query result is obtained through the query statement.
[0023] Optionally, after storing the query condition group as a historical query group, the method further includes:
[0024] In response to the query group name input by the user, the historical query group is renamed.
[0025] Optionally, after storing the query condition group as a historical query group, the method further includes:
[0026] In response to a target query group selected by a user from one or more historical query groups, target data items included in the target query group and target matching conditions corresponding one-to-one to the target data items are displayed.
[0027] In a second aspect, an embodiment of the present application further provides a data query device, the device comprising: an acquisition module, a first generation module, a second generation module and a query module;
[0028] The acquisition module is used to acquire the query condition pool selected by the user;
[0029] The first query module is used to assemble the query condition pool into the statistical ledger SQL statement to generate a query statement; the query condition pool includes optional data items and optional matching conditions;
[0030] The second query module is used to generate a query condition group in response to a target query condition selected by a user from the query condition pool;
[0031] The query module is used to obtain a first query result through the query statement based on the query condition group and a first matching field input by a user; the matching field is a field included in the data item.
[0032] In a third aspect, an embodiment of the present application further provides a data query device, the device comprising: a memory and a processor;
[0033] The memory is used to store program codes and transmit the program codes to the processor;
[0034] The processor is used to execute the steps of the data query method described in any implementation manner of the first aspect according to the program code.
[0035] In a fourth aspect, an embodiment of the present application further provides a computer-readable storage medium, in which a computer program is stored. When the computer program runs on a data query device, the data query device executes the steps of the data query method described in any implementation of the first aspect.
[0036] Compared with the prior art, this application has the following beneficial effects:
[0037] The embodiment of the present application provides a data query method, in which, first, a query condition pool selected by a user is obtained; then, the query condition pool is assembled into a statistical ledger SQL statement to generate a query statement; the query condition pool includes optional data items and optional matching conditions; then, in response to the target query condition selected by the user from the query condition pool, a query condition group is generated; finally, based on the query condition group and the first matching field input by the user, a first query result is obtained through a query statement; the matching field is a field included in the data item. Thus, the user can flexibly select the target data item and the target matching condition according to the query requirements, and provide the first matching field, thereby realizing personalized query requirements, improving the efficiency of data query, and allowing the user to conveniently, quickly and accurately query and obtain the required query results. BRIEF DESCRIPTION OF THE DRAWINGS
[0038] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0039] Figure 1 A flow chart of a data query method provided in an embodiment of the present application;
[0040] Figure 2 A schematic diagram of a target query condition selection interface provided in an embodiment of the present application;
[0041] Figure 3 A schematic diagram of a query interface provided in an embodiment of the present application;
[0042] Figure 4 A schematic diagram of a query result provided in an embodiment of the present application;
[0043] Figure 5 A schematic diagram of a target query group display interface provided in an embodiment of the present application;
[0044] Figure 6 A schematic diagram of a data query device provided in an embodiment of the present application;
[0045] Figure 7 A structural diagram of a data query device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0046] The data query method and related devices provided in the present application can be used in the field of big data. The above is only an example and does not limit the application field of the data query method and related devices provided in the present application.
[0047] The terms "first", "second", "third" and "fourth" etc. in the specification, claims and drawings of this application are used to distinguish different objects rather than to limit a specific order.
[0048] In the embodiments of the present application, the words "as an example" or "for example" are used to indicate examples, illustrations or explanations. Any embodiment or design described as "as an example" or "for example" in the embodiments of the present application should not be interpreted as being more preferred or more advantageous than other embodiments or designs. Specifically, the use of the words "as an example" or "for example" is intended to present the relevant concepts in a specific way.
[0049] The terms used in the implementation section of this application are only used to explain the specific embodiments of this application and are not intended to limit this application.
[0050] In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0051] See also Figure 1 , which is a flow chart of a data query method provided in an embodiment of the present application, the method comprising:
[0052] S101: Acquire a query condition pool selected by a user.
[0053] Specifically, the query condition pool includes optional data items and optional matching conditions. Users can pre-create multiple query condition pools according to different application scenarios. When data query is needed, users select the appropriate query condition pool according to the query requirements, so that the target query conditions can be selected more efficiently.
[0054] As an example, the query condition pool may include multiple data items such as customer name, customer number, payment type, and amount payable, as well as multiple optional matching conditions such as fuzzy matching, exact matching, greater than, less than, greater than or equal to, less than or equal to, equal to, and not equal to, and each data item is associated with one or more optional matching conditions through its data type. For example, data types may include but are not limited to text, numbers, and dates. For data items belonging to the text data type, two optional matching conditions, exact matching and fuzzy matching, may be provided; for data items belonging to the number or date data type, multiple optional matching conditions, including greater than, less than, greater than or equal to, less than or equal to, equal to, and not equal to, may be provided.
[0055] As an example, the optional data items and optional matching conditions input by the user can be obtained in advance, and then a query condition pool can be generated based on the optional data items and the optional matching conditions. Each user can create multiple query condition pools so that the user can quickly switch query requirements and perform data queries more efficiently. For example, a first query condition pool including data items such as factoring agreement number, financing terms, and recourse can be established for product information, and a second query condition pool including data items such as customer name, amount of payable, and due date of payable can be established for transaction conditions.
[0056] S102: Assemble the query condition pool into the statistical ledger SQL statement to generate a query statement.
[0057] A statistical ledger is a tool for recording and summarizing statistical data. It can systematically record and summarize data. Each statistical ledger has a corresponding SQL statement. Statistical ledger SQL statements are usually used to extract and summarize data from the database in order to generate reports or perform analysis. According to actual needs, statistical ledger SQL statements can include elements such as selecting columns, table names, conditional filtering, grouping, aggregate functions, sorting, limiting result sets, connecting multiple tables, subqueries, and window functions.
[0058] As an example, after obtaining the query condition pool, the query condition pool can be parsed and assembled into a statistical ledger SQL statement to obtain a query statement. The query statement can form a specific SQL statement based on the query condition group provided by the user to query the database to obtain the corresponding query result.
[0059] S103: generating a query condition group in response to a target query condition selected by a user from a query condition pool.
[0060] Specifically, Figure 2 As shown, the user can flexibly select the target data item and the target comparison operator (ie, the target matching condition) according to the query requirement, thereby generating a target query condition. One or more target query conditions selected according to the query requirement constitute a query condition group.
[0061] For example, the user selects the customer name as the target data item from the optional data items in the query condition pool. In response to the target data item selected by the user, the data type of the target data item is identified as text. Then, the optional matching conditions corresponding to the data type of text can be determined from the query condition pool as fuzzy matching and exact matching, and the optional matching conditions are displayed to the user. Then, the user selects exact matching as the target matching condition from the optional matching conditions. According to the target data item and the target matching condition, the target query condition of customer name-exact matching can be generated. The user can select multiple target query conditions at the same time to form a query condition group. For example, the amount of payables can be selected as another target data item, and greater than can be selected as another target matching condition, so as to obtain the target query condition of the amount of payables-greater than, and form a query condition group including two target query conditions of customer name-exact matching and the amount of payables-greater than. In this way, multiple target query conditions can be provided at the same time, so as to find and obtain query results that meet multiple target query conditions from the database at the same time, thereby improving the fit between the query results and the query requirements.
[0062] Optionally, in the target query condition selection interface, add, delete and save buttons may be provided. By clicking the add button, a target query condition may be added; by clicking the delete button, one or more selected target query conditions may be deleted; by clicking the save button, a query condition group consisting of one or more target query conditions may be stored as a historical query group.
[0063] S104: Obtain a first query result through a query statement based on the query condition group and the first matching field input by the user.
[0064] The matching fields are fields contained in the data items. Figure 3 As shown in the figure, in the query condition group of query 1, the target query condition included is customer name-fuzzy match. The user can enter the first matching field in the comparison content and click the query button to get the first query result, such as Figure 4 shown.
[0065] In addition, in Figure 3 The query interface shown may also provide a reset button to clear the matching fields entered in the comparison content.
[0066] In the embodiment of the present application, first, a query condition pool selected by the user is obtained; then, the query condition pool is assembled into a statistical ledger SQL statement to generate a query statement; the query condition pool includes optional data items and optional matching conditions; then, in response to the target query condition selected by the user from the query condition pool, a query condition group is generated; finally, based on the query condition group and the first matching field input by the user, a first query result is obtained through a query statement; the matching field is a field included in the data item. Thus, the user can flexibly select the target data item and the target matching condition according to the query requirements, and provide the first matching field, thereby realizing personalized query requirements, improving the efficiency of data query, and allowing the user to conveniently, quickly and accurately query and obtain the required query results.
[0067] In another embodiment provided by the present application, after the query condition group is generated, the query condition group can be stored as a historical query group. If there is a historical query group that can meet the current query requirements, for example, it is necessary to obtain multiple query results containing the same data items but with different matching fields, the user can directly select the target query group from the historical query group, thereby eliminating the need to repeatedly select the same target query group, thereby improving query efficiency.
[0068] Specifically, the second query result can be obtained through the query statement based on the target query group selected by the user from one or more historical query groups and the second matching field input by the user. For example, when querying the payment details of customer A through the data item of customer name, the query condition group used is stored as the historical query group X. Then, when it is necessary to query the payment details of customer B through the data item of customer name, the historical query group X can be directly selected as the target query group, and the second matching field, such as the name of customer B, can be entered into the information column of the comparison content for querying. Thus, the query statement can form a specific SQL statement according to the query condition and the second matching field in the target query group, and the second query result can be obtained conveniently.
[0069] Optionally, the historical query value may be renamed in response to the query group name input by the user. Figure 3 As shown, you can click the Modify button and enter the query group name to modify the name of the historical query group, so that users can distinguish different historical query groups and quickly find the required target query group from multiple historical query groups. For example, you can click the Modify button on the right side of "Query 1" and enter the query name "Report" to modify the name of the historical query group "Query 1" to "Report". Optionally, in the following example, Figure 3 In the query interface, each label of the historical query group is provided with a corresponding modify button and delete button, wherein the modify button is used to modify the name of the historical query group, and the delete button is used to delete the corresponding historical query group. In addition, the query interface may also include a new button for adding a new historical query group.
[0070] In another embodiment provided by the present application, in response to a target query group selected by a user from one or more historical query groups, the target data items contained in the target query group and the target matching conditions corresponding to the target data items may be displayed. Figure 5 As shown, there are two historical query groups, "Report" and "Daily Settlement". When "Report" is selected as the target query group, the target data items (ie, customer numbers) contained in the target query group and the target matching conditions (ie, equals) corresponding to the target data items will be displayed.
[0071] As an implementation method, the data type of a data item may be identified by the following code:
[0072]
[0073] As an implementation method, the association relationship between the data type and the optional matching condition can be established through the following code:
[0074]
[0075]
[0076]
[0077] As an implementation method, the query condition pool can be assembled into the statistical ledger SQL statement through the following code:
[0078]
[0079]
[0080]
[0081]
[0082]
[0083] See also Figure 6 , which is a schematic diagram of a data query device provided in an embodiment of the present application, the device includes: an acquisition module 601, a first generation module 602, a second generation module 603 and a query module 604;
[0084] Acquisition module 601, used to acquire the query condition pool selected by the user;
[0085] The first query module 602 is used to assemble the query condition pool into the statistical ledger SQL statement to generate a query statement; the query condition pool includes optional data items and optional matching conditions;
[0086] The second query module 603 is used to generate a query condition group in response to a target query condition selected by a user from the query condition pool;
[0087] The query module 604 is used to obtain a first query result through a query statement based on the query condition group and a first matching field input by the user; the matching field is a field included in the data item.
[0088] Therefore, users can flexibly select target data items and target matching conditions according to query requirements, and provide the first matching field, thereby realizing personalized query requirements and improving the efficiency of data query, so that users can query and obtain the required query results conveniently, quickly and accurately.
[0089] Optionally, the second generation module 603 is specifically used to: identify the data type of the target data item in response to the target data item selected by the user from the optional data items; determine the optional matching conditions corresponding to the data types of each target data item from the query condition pool; and generate a query condition group in response to the target matching conditions corresponding to each target data item selected by the user from the optional matching conditions.
[0090] Optionally, another data query device provided by the present application also includes: a condition pool construction module, used to obtain optional data items and optional matching conditions input by a user; and generate a query condition pool based on the optional data items and the optional matching conditions.
[0091] Optionally, another data query device provided by the present application also includes: a multiplexing module, used to store the query condition group as a historical query group; based on the target query group selected by the user from one or more historical query groups, and the second matching field entered by the user, obtain a second query result through a query statement.
[0092] Optionally, another data query device provided by the present application further includes: a renaming module, configured to rename the historical query group in response to a query group name input by a user.
[0093] Optionally, another data query device provided by the present application also includes: a display module, which is used to display the target data items contained in the target query group and the target matching conditions corresponding to the target data items in response to the target query group selected by the user from one or more historical query groups.
[0094] See also Figure 7 , this figure is a structural diagram of a data query device provided in an embodiment of the present application, and the device includes: a memory 701 and a processor 702.
[0095] Memory 701: used to store program codes and transmit the program codes to the processor.
[0096] Processor 702: used to execute the steps of the above data query method according to the instructions in the program code.
[0097] In addition, the present application also provides a computer-readable storage medium, in which computer instructions are stored. When the computer instructions are executed on a data query device, the data query device executes the steps of the above-mentioned data query method.
[0098] It should be noted that each embodiment in this specification is described in a progressive manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the device and system embodiments, since they are basically similar to the method embodiments, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiments. The device and system embodiments described above are merely schematic, wherein the units described as separate components may or may not be physically separated, and the components indicated as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without paying creative labor.
[0099] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any changes or substitutions that can be easily thought of by a person skilled in the art within the technical scope disclosed in the present application should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.
Claims
1. A data query method, characterized in that: The method comprises: Get the query condition pool selected by the user; Assembling the query condition pool into the statistical ledger SQL statement to generate a query statement; the query condition pool includes optional data items and optional matching conditions; In response to a target query condition selected by a user from the query condition pool, generating a query condition group; Based on the query condition group and a first matching field input by a user, a first query result is obtained through the query statement; the matching field is a field included in the data item.
2. The method according to claim 1, characterized in that The generating a query condition group in response to a target query condition selected by a user from the query condition pool includes: In response to a target data item selected by a user from the selectable data items, identifying a data type of the target data item; Determine, from the query condition pool, optional matching conditions corresponding to the data types of the respective target data items; In response to the target matching conditions corresponding to the respective target data items selected by the user from the optional matching conditions, a query condition group is generated.
3. The method according to claim 2, characterized in that When the data type includes text, the optional matching conditions include exact matching and fuzzy matching; when the data type includes numbers or dates, the optional matching conditions include equal to, not equal to, less than, less than or equal to, greater than, and greater than or equal to.
4. The method according to claim 1, characterized in that: Before obtaining the query condition pool selected by the user, the method further includes: Get optional data items and optional matching conditions entered by the user; A query condition pool is generated based on the optional data items and the optional matching conditions.
5. The method according to claim 1, characterized in that After generating a query condition group in response to a target query condition selected by a user from the query condition pool, the method further includes: storing the query condition group as a historical query group; Based on the target query group selected by the user from one or more historical query groups and the second matching field input by the user, a second query result is obtained through the query statement.
6. The method according to claim 5, characterized in that After storing the query condition group as a historical query group, the method further includes: In response to the query group name input by the user, the historical query group is renamed.
7. The method according to claim 5, characterized in that After storing the query condition group as a historical query group, the method further includes: In response to a target query group selected by a user from one or more historical query groups, target data items included in the target query group and target matching conditions corresponding one-to-one to the target data items are displayed.
8. A data query device, characterized in that: The device comprises: an acquisition module, a first generation module, a second generation module and a query module; The acquisition module is used to acquire the query condition pool selected by the user; The first query module is used to assemble the query condition pool into the statistical ledger SQL statement to generate a query statement; the query condition pool includes optional data items and optional matching conditions; The second query module is used to generate a query condition group in response to a target query condition selected by a user from the query condition pool; The query module is used to obtain a first query result through the query statement based on the query condition group and a first matching field input by a user; the matching field is a field included in the data item.
9. A data query device, characterized in that: The device comprises: a memory and a processor; The memory is used to store program code and transmit the program code to the processor; The processor is used to execute the steps of the data query method according to any one of claims 1 to 7 according to the program code.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program. When the computer program runs on a data query device, the data query device executes the steps of the data query method according to any one of claims 1 to 7.