I have a table (tng_people) and I want Sql to select all the people with the same birthday.
I want personId, Lastname, Surname, Birthdate and deathdate.
SELECT P.birthDate, DATE_FORMAT(birthDate,'%d %b %Y'), GROUP_CONCAT(CONCAT(familyName, " ",givenName)) AS PersonNames
FROM person P
WHERE concat( givenName, familyName, birthDate) IS NOT NULL
GROUP BY P.birthDate;
2
Answers
You could use an
exists
clause to filter for persons for whom another person exists with the same birthday:Instead of
GROUP BY
you could useORDER BY
to bring persons with the same birthday together :