Our Laravel web app runs several reports for users with results returned and displayed in DataTables.
Currently, each report has a single parameter and can only take one value.
So we currently have a report called "Users by Token" and for this you have to enter a token name to get all the users who have that token assigned. The query is obviously something like:
SELECT USER from USERTOKEN WHERE TOKEN = '<parameter>'
That's all great and good, but now the users are asking for two separate requirements.
First, they would like to have the ability to provide several values for the token like:
SELECT USER FROM USERTOKEN WHERE TOKEN='AC10.1' OR TOKEN = 'PR10.1' OR TOKEN='HR11.1'
Second they want the ability to have wildcards like"
SELECT USER FROM USERTOKEN WHERE TOKEN like 'AC10.%'
To combine these two things we just have to do something like:
SELECT USER FROM USERTOKEN WHERE TOKEN like 'AC10.%' OR TOKEN like 'PR10.1' OR TOKEN like 'HR11.1'
So when the users enter a "*" in their query, we'll just replace that with a '%' in the query and so on. The like directive should work for exact matches I think if we don't have a '%' in the query, right?
I can't help it think there's probably a better way to do this. How do larger applications handle this problem? (I realize the dangers of using wildcards when it comes to rows returned).