2f262ebebd76067ea983cfeb7454ed626a450c61
angie
  Fri Jan 6 15:45:54 2017 -0800
In mysql 5.7 with the default configuration, it is now an error if a SELECT list using DISTINCT does not include all ORDER BY fields.  The solution is to add the ORDER BY fields to the end of the SELECT list if they're not already included.  The extra columns returned by the query are ignored.  refs #18626, #18597

diff --git src/hg/hgc/hgc.c src/hg/hgc/hgc.c
index 8133315..9486106 100644
--- src/hg/hgc/hgc.c
+++ src/hg/hgc/hgc.c
@@ -10089,31 +10089,34 @@
     sqlFreeResult(&sr);
     }
 
 /* link to Ensembl DECIPHER Patient View page */
 printf("<B>Patient View: </B>\n");
 printf("More details on patient %s at ", itemName);
 printf("<A HREF=\"%s%s\" target=_blank>",
        "https://decipher.sanger.ac.uk/patient/", itemName);
 printf("DECIPHER</A>.<BR><BR>");
 
 /* print position info */
 printPosOnChrom(chrom, start, end, strand, TRUE, itemName);
 
 /* print UCSC Genes in the reported region */
 sqlSafef(query, sizeof(query),
-      "select distinct t.name from knownCanonToDecipher t, kgXref x  where value ='%s' and x.kgId=t.name order by geneSymbol", itemName);
+      "select distinct t.name "
+      // mysql 5.7: SELECT list w/DISTINCT must include all fields in ORDER BY list (#18626)
+      ", geneSymbol "
+      "from knownCanonToDecipher t, kgXref x  where value ='%s' and x.kgId=t.name order by geneSymbol", itemName);
 sr = sqlMustGetResult(conn, query);
 row = sqlNextRow(sr);
 if (row != NULL)
     {
     printf("<BR><B>UCSC Canonical Gene(s) in this genomic region: </B><UL>");
     while (row != NULL)
         {
 	sqlSafef(query2, sizeof(query2),
         "select geneSymbol, kgId, description from kgXref where kgId ='%s'", row[0]);
 	sr2 = sqlMustGetResult(conn2, query2);
 	row2 = sqlNextRow(sr2);
 	if (row2 != NULL)
             {
 	    printf("<LI>");
             printf("<A HREF=\"%s%s\" target=_blank>","./hgGene\?hgg_chrom=none&hgg_gene=", row2[1]);