Article From:

java webNovice, recently encountered a requirement is for a table with n fields, the form in the web page also has n input boxes, users can fill in any number of fields of search keywords, and then need to be able to submit any number of keywords combined queries.
Looked for the data that is to use multi-column index to do, but did not find a specific approach, I hope that the boss can from the MySQL database level and code level to explain how this kind of problem should be solved.

Answer 0:

Determine whether all fields have values, and dynamically splice the SQL statements for processing.

Answer 1:

It’s nothing to do with the index. The index just speeds up the query. You should get GET or POST values on the Java side, then do SQL splicing, and then execute them.

Answer 2:

Generally speaking, you can try to analyze whether query conditions have parent-child relationship to establish an index including multiple indexes. Once the index is possible to query independently, it is not the first field that can not appear in the joint index.

Answer 3:

According to the data from the foreground, to extract all the attribute names and attribute values, and then determine whether the attribute values have value, if there is a value, according to the attribute name to stitch the corresponding SQL statement query conditions, and ultimately execute the entire SQL

Leave a Reply

Your email address will not be published. Required fields are marked *