I believe you need something like
select count(*)
from customer c
where c.key = 'lastName'
and c.value in ('Johnson', 'Brett', 'Jack')
so you can count all the customers
with last names including Johnson
, Brett
and Jack
.
With you current data model, if you want to find all people with a specific firstName
and lastName
you must join two instances of customer
table as
select count(*)
from customer c1
join customer c2 on c1.user_id = c2.user_id
where c1.key = 'firstName'
and c2.key = 'lastName'
and c1.value = 'John'
and c2.value = 'Doe'
and it goes more complex if you need to search upon more fields.
By the way, why do you use such a data-model in an RDBMS? If you have an schema-less model, why don't you use a NoSQL database such as Mongo?