- First, I am trying to count the primary keys of a table that were NOT referenced as foreign keys in another table.
- In addition, I want to filter the search by using the LIKE clause to display only those containing a certain letter of a given attribute.
See the explanation in the image below ( original here ):
I'm using this QUERY:
SELECT l.identifier AS id, l.name AS listName, COUNT(p.list_identifier) AS regCount
FROM list AS l
LEFT OUTER JOIN person AS p ON l.identifier = p.list_identifier
WHERE p.list_identifier IS NULL
GROUP BY l.name
However, it counts the foreign keys that were not referenced and without the LIKE clause. Please, if anyone can give me an example of QUERY to do this search, I appreciate it.