문제

My image, explanation

  • I need to count the foreign key that does not exist, as shown in Fig. And containing the letter 'a' in the name of the list.
  • I can only count values​​, but no way to specify the names with the letter 'a'.

I'm using for count:

SELECT l.identifier AS id, l.name AS listName, COUNT(p.list_identifier)
AS regCount FROM list AS l LEFT JOIN person AS p ON l.identifier = p.list_identifier
WHERE p.list_identifier IS NULL GROUP BY l.name;

Help me, please.

도움이 되었습니까?

해결책

Try using a left outer join & COUNT(DISTINCT ...)

SELECT COUNT(DISTINCT l.identifier) AS regCount
FROM list AS l LEFT OUTER JOIN person AS p ON l.identifier = p.list_identifier
WHERE l.Name LIKE '%a%'
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top