Creating Custom SQL Queries

I’ve found the solution.

The expression should be:

%{{$_GET.filter}}%

Phew!

Resurrecting an old thread, but this is exactly what I was looking for! Have you found that empty parameters will still return all results like when using the Wappler-generated queries?

Hi @zbot11 - yes, from memory it does.

As the inputs are delimited with % then an empty string simply returns two wildcards ( %% ) which by definition match everything

1 Like

Is there a way to implement using sort and dir variables with custom queries? I can’t seem to find a way to make it work…

Please check George’s reply here a few replies above in this topic:

But @george says that they can’t be used for sorting order because they handle column names…

Yes, that’s right. You cannot use column names as parameters.

So is there a way to do sort/dir in custom queries?

You can use stored procedures and call them in the custom query dialog. Here’s a discussion about this:

I thought prepare and bindParam avoided injections in PHP and knex took care of them for js.

2 posts were split to a new topic: Problems with custom queries

NOTE:
Variables in MySQL (@VarName) do not work with Custom Query as of v3.7.6.
Alternative is to create a Stored Procedure (SP) and call SP from custom query.