Database query builder: comparing two columns against each other

Basically what I want to do is add a “WHERE column1 > column2” condition in the Database query builder. My guesses for that simple problem don’t work (toggle works fine)?

wapller

Hi,

From what I know, that is not possible via query builder UI.
You should look to convert your query to custom.

Is there a way to convert my existing Database Query to a custom one? As far as I can tell, I can’t even copy (&paste) the statement from the Query Builder UI window.

Open the server action in editor, there you can see the query which you can copy.
If you have any conditional where clauses, you will have to convert that manually in the final custom query using case when etc.

How to copy anything from down there? I can’t even click in the statement field (at the bottom of the Conditions tab, that is)

image

You can’t copy from UI. Open the server action in editor, there you will see the string that you see in the UI. That you can copy and use to create your custom query.

Ok thanks, I have tried that but I have no clue how to convert all the condition toggles in the query (there are a bunch of them).
Given that the theoretical solution would be only a couple of keystrokes away, is there really no other way to fiddle the “WHERE onefield <= otherfield” in between somewhere?

Not that I know of. Maybe @Teodor can help.

Another option might be to keep your query as it is - not use a custom query, but to use a repeat to compare the two fields.

Ok thanks to all for your input, I ended up by simply hiding the affected rows. Nice to see that many roads lead to Rome =)

1 Like