SELECT p.name
FROM user p
LEFT JOIN horoscope ph
ON LEFT(ph.date_start, 2) < convert(DAYOFMONTH(p.birthday), CHAR)
AND LEFT(ph.date_end, 2) > convert(DAYOFMONTH(p.birthday), CHAR)
AND RIGHT(ph.date_start, 2) < convert(MONTH(p.birthday), CHAR)
AND RIGHT(ph.date_end, 2) > convert(MONTH(p.birthday), CHAR)
WHERE ph.name = 'Aries';
SELECT *
FROM user `u`
LEFT JOIN horoscope `h` ON LEFT(`h`.date_start, 2) < DATE_FORMAT(`u`.birthday, '%d')
AND LEFT(`h`.date_end, 2) > DATE_FORMAT(`u`.birthday, '%d')
AND RIGHT(`h`.date_start, 2) < DATE_FORMAT(`u`.birthday, '%m')
AND RIGHT(`h`.date_end, 2) > DATE_FORMAT(`u`.birthday, '%m')
WHERE `h`.name = 'Aquarius';