db_build_query_browse() query changes ("DISTINCT %s, %s", field, field)

This commit is contained in:
Kai Elwert 2010-12-05 16:07:44 +01:00 committed by Julien BLACHE
parent bf86cf45bd
commit d8bf5eedce

View File

@ -1100,17 +1100,17 @@ db_build_query_browse(struct query_params *qp, char *field, char **q)
return -1;
if (idx && qp->filter)
query = sqlite3_mprintf("SELECT DISTINCT %s COLLATE DAAP FROM files WHERE data_kind = 0 AND disabled = 0 AND %s != ''"
" AND %s %s;", field, field, qp->filter, idx);
query = sqlite3_mprintf("SELECT DISTINCT %s COLLATE DAAP, %s FROM files WHERE data_kind = 0 AND disabled = 0 AND %s != ''"
" AND %s %s;", field, field, field, qp->filter, idx);
else if (idx)
query = sqlite3_mprintf("SELECT DISTINCT %s COLLATE DAAP FROM files WHERE data_kind = 0 AND disabled = 0 AND %s != ''"
" %s;", field, field, idx);
query = sqlite3_mprintf("SELECT DISTINCT %s COLLATE DAAP, %s FROM files WHERE data_kind = 0 AND disabled = 0 AND %s != ''"
" %s;", field, field, field, idx);
else if (qp->filter)
query = sqlite3_mprintf("SELECT DISTINCT %s COLLATE DAAP FROM files WHERE data_kind = 0 AND disabled = 0 AND %s != ''"
" AND %s;", field, field, qp->filter);
query = sqlite3_mprintf("SELECT DISTINCT %s COLLATE DAAP, %s FROM files WHERE data_kind = 0 AND disabled = 0 AND %s != ''"
" AND %s;", field, field, field, qp->filter);
else
query = sqlite3_mprintf("SELECT DISTINCT %s COLLATE DAAP FROM files WHERE data_kind = 0 AND disabled = 0 AND %s != ''",
field, field);
query = sqlite3_mprintf("SELECT DISTINCT %s COLLATE DAAP, %s FROM files WHERE data_kind = 0 AND disabled = 0 AND %s != ''",
field, field, field);
if (!query)
{