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?

asked Oct 27, 2020 at 15:49

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.

Rafael Corrêa Gomes
13.9k15 gold badges92 silver badges190 bronze badges
answered Oct 27, 2020 at 20:22

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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.