I would like to do something like this:

craft.entries.section('mySection').field1('> field2').all()

And it should return all the entries in mySection whose field1 value is greater than their field2 value.

Is it possible?


You could just do (Assuming your field1 and field2 are set to numbers as Field type):


as your query then within your loop:

{% for entry in entries %}
    {% if entry.field1 > entry.field2 %}
        // Show the entry
    {% endif %}
{% endfor %}

It depends on what you need but this would work.

  • 2
    This seems horrible inefficient, return ALL entries when you only need certain ones. Is there no other way? – Gary Reckard Aug 2 '19 at 19:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.