A, An, The

From LinuxMCE
Revision as of 03:50, 10 June 2013 by Tschak909 (Talk | contribs)

(diff) ←Older revision | view current revision (diff) | Newer revision→ (diff)
Jump to: navigation, search

SQL Query

void Media_Plugin::PopulateFileBrowserInfoForAttribute(MediaListGrid *pMediaListGrid,int PK_AttributeType_Sort, int PK_Attribute, string &sPK_File_Or_Disc,string sTable)

sql Query, needs work.

       string sSQL_Sort = "SELECT PK_Attribute,CASE WHEN SUBSTRING_INDEX(Name, ' ', 1) IN ('a','an','the') THEN CONCAT(SUBSTRING(Name, INSTR(Name, ' ')+1), ', ', SUBSTRING_INDEX(Name, ' ',1)) ELSE Name END AS Name,min(FK_Picture) AS FK_Picture FROM " + sTable + " JOIN " +
               sTable + "_Attribute ON FK_" + sTable + "=PK_" + sTable + " JOIN Attribute ON " +
               sTable + "_Attribute.FK_Attribute=PK_Attribute AND FK_AttributeType=" + StringUtils::itos(PK_AttributeType_Sort) +
               " LEFT JOIN Picture_Attribute ON Picture_Attribute.FK_Attribute=PK_Attribute WHERE " +
               (sTable=="File" ? "IsDirectory=0 AND " : "") +
               "PK_" + sTable + " in (" + sPK_File_Or_Disc + ") GROUP BY PK_Attribute,IF(SUBSTRING(Name,1,4)='The ',SUBSTRING(Name,5),Name)";