sql >> Base de Datos >  >> RDS >> Mysql

Unirse a la tabla según el valor de la columna en la tabla principal

Algo como

SELECT *
FROM notificationTable notification   
LEFT JOIN commentTable comment
ON (notification.typeID = comment.ID AND notification.type == 'comment')
LEFT JOIN evenTable event
ON (notification.typeID = event.ID AND notification.type == 'accept')
WHERE notification.userID = 2

Pero recomiendo enfáticamente rediseñar su sistema para evitar relaciones polimórficas...