I am using a entity_query, where I get a fatal error because the sort field is not found. The integer field (field_year exists) and exists in the database in the membership__field_year table in the field_year_value row.

query = $this->entity_query->get('membership');
$query->condition('field_membership_member', $this->member->id());
$query->condition('status', 1);
$query->sort('field_year' , 'DESC');

This is the error I get:

Drupal\Core\Database\DatabaseExceptionWrapper: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'membership__field_year.field_year_value' in 'field list'

How do I sort on an integer field?

1 Answer 1


Found the culprit. Apparently I was calling $query->execute() twice.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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