AudioFerret/v1/sql/qryCbx Titles

from HTYP, the free directory anyone can edit if they can prove to me that they're not a spambot
< AudioFerret‎ | v1‎ | sql
Jump to: navigation, search

SQL

<mysql>CREATE OR REPLACE VIEW qryCbx_Titles AS

 SELECT
   t.ID,
   CONCAT_WS(' - ',IF(t.name IS NULL,t.track,t.name),IF(t.Artist_ID IS NULL,aa.Name,at.Name),ab.Name) AS Track,
   t.album_id
 FROM
 (
   (Titles AS t LEFT JOIN Artists AS at ON t.Artist_ID=at.ID)
    LEFT JOIN Albums AS ab ON t.Album_ID=ab.ID
 ) LEFT JOIN Artists AS aa ON ab.idArtist=aa.ID

ORDER BY t.name,t.track;</mysql>