Skip to main content
ruslana544145
Participating Frequently
February 17, 2021
Question

Exact Match with column separated with a delimiter and Appian Query

  • February 17, 2021
  • 9 replies
  • 0 views

Is there a best practice with regards to finding an exact match from a delimited list inside a MySQL table column using a query rule?

Assume that standard, better solutions are out of scope - i.e. mapping tables to avoid the delimited lists inside columns, or using multiple rows for each ID and account number.

Example:

Clients Table

ID Account Numbers
1 12345, 123456
2 123456, ABCDEF

Query for 1234 should return no results (exact match desired). Query for 123456 should return 1,2. Query for 12345 should return 1, but not 2. ("includes" in Appian would return 1,2)

My current solution is using MD5, but wondering if there is a better method.

ID Account Numbers Account Numbers MD5
1 12345, 123456 827CCB0EEA8A706C4C34A16891F84E7B, E10ADC3949BA59ABBE56E057F20F883E
2 123456, ABCDEF E10ADC3949BA59ABBE56E057F20F883E, 8827A41122A5028B9808C7BF84B9FCF6

Query using "includes" and MD5(parameter) correctly returns expected results.

i.e. A user inputs "12345" in a text field, it is passed into md5hash(), and that is passed to the query on the table which then uses "includes".

a!queryFilter(

  field: "accountNumberMD5",

  operator: "includes",

  value: md5hash(ri!accountNumber)

)

9 replies

stefanhelzle0001
Brainy
February 17, 2021

I would try to solve that in DB. Maybe a stored procedure triggered by an insert populating a separate table with account numbers and matching ids.

ruslana544145
Participating Frequently
February 17, 2021

Thank you for the quick response [mention:126a676c85024855948336691b0a7b92:e9ed411860ed4f2ba0265705b8793d05].

I should add more context:

This is within an imitation of a materialized view (table + triggers on a main table and secondary, key value pair table) and is related to search. We have a number of columns identified as important for search (around 16) so the materialized view imitation draws the first few columns from the main table and the others are populated using triggers and group_concat.

The ask is that with one query (for performance reasons) we can return a usable datasubset within a paging grid. A view is out of the question due to the sheer size of both the main and KVP tables.

stefanhelzle0001
Brainy
February 17, 2021

OK. Then why not prepare the search table exactly as needed? Each combination of matching values becomes one row.