Help filtering MySQL result with first name and last name in different table columns

Hello Wapplers,
I am stuck, I’m trying to filter a mysql query where first name and last name is in different columns with only one text field. When filtering on first name it works and also last name works.
But when searching for “firstname lastname” i can’t get it to work.

At the moment this is my filter:

Any guidance would be much appreciated.

Cheers!

I create MySQL views that combine the information I want and query the view instead of the table… so the view has a column full_name which I search in my Server Action.

Hope that makes sense!

3 Likes

If you have a single filter input field and want to search many columns, another approach is to convert the entered string into an array and use each element as a separate search criterion. Eg here I’m using the first word to search several columns:

image
If I want to use the second word too, I’ll duplicate these, but using {{search.split(" ")[1]}} and so on.

In this case, I’m searching about 15 columns, so it wouldn’t be practical to combine them into a single column for searching. Having to specify each array element doesn’t seem an ideal solution but I don’t think it’s possible to generate the query dynamically with Wappler. In any case, this solution works well. In this example, the screenshot show only three of about 80 query parameters.

2 Likes

Thanks Antony,
If I was administrating the DB this would have been a great and easy solution. But the DB
is in the hands of the customer and I have very restricted access.

Cheers!