Tengo una tabla playlist, playlist_track, playlist_adversiting. Intento realizar una consulta donde retorne todos los registro de playlist con la cantidad correspondiente a sus otras tablas:
SQL:
SELECT
playlist.*,
user_created.user_id as user_created_id,
user_created.user_name as user_created_name,
user_updated.user_id as user_updated_id,
user_updated.user_name as user_updated_name,
COUNT( playlist_track.playlist_track_id ) as track_count,
COUNT( playlist_advertising.playlist_advertising_id ) AS advertising_count
FROM playlist
INNER JOIN user user_created ON user_created.user_id = playlist.playlist_createdBy
INNER JOIN user user_updated ON user_updated.user_id = playlist.playlist_updatedBy
LEFT JOIN playlist_track ON playlist_track.playlist_track_id_playlist = playlist.playlist_id
LEFT JOIN playlist_advertising ON playlist_advertising.playlist_advertising_id_playlist = playlist.playlist_id
GROUP BY
playlist.playlist_id