0

The zd_user_id is our customer custom attribute.

$customerCollection = $this->customerFactory->create();
$customers = $customerCollection->addAttributeToFilter(
    [
        ['attribute' => 'zd_user_id', 'null' => true],
        ['attribute' => 'zd_user_id', 'eq' => ''],
        ['attribute' => 'zd_user_id', 'eq' => 'NO FIELD']
    ],
    '',
    'left'
)

How could I get all customers with the attribute zd_user_id equal true via SQL?

1 Answer 1

2
select * from eav_attribute where attribute_code='zd_user_id';

from this query, you get the attribute id and you also get the backend_type for this attribute.

Assuming the backend type is int.

select count(*) from customer_entity_int where attribute_id=<attribute_id_found> and value=1;

If it's varchar you can change the query to search in the table customer_entity_varchar.

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.