f56706efd48606f7211343afb57347aa0f116ec1
chmalee
  Tue Feb 26 13:25:06 2019 -0800
Partly fixing bug in hgc where different results from the clicked item were displayed, refs #22996

diff --git src/hg/hgc/hgc.c src/hg/hgc/hgc.c
index 89e4236..58f1232 100644
--- src/hg/hgc/hgc.c
+++ src/hg/hgc/hgc.c
@@ -21425,35 +21425,34 @@
     {
     doPgSnp(ct->tdb, itemName, ct);
     }
 else
     {
     if (ct->dbTrack)
 	{
 	char where[512];
 	int rowOffset;
 	char **row;
 	struct sqlConnection *conn = hAllocConn(CUSTOM_TRASH);
 	struct sqlResult *sr = NULL;
 	int start = cartInt(cart, "o");
 	int end = cartInt(cart, "t");
 
-	if (ct->fieldCount < 4)
-	    sqlSafefFrag(where, sizeof(where), "chromStart = '%d'", start);
-	else
+	sqlSafefFrag(where, sizeof(where), "chromStart = '%d' and chromEnd = '%d'", start, end);
+	if (ct->fieldCount >= 4)
 	    {
-	    sqlSafefFrag(where, sizeof(where), "name = '%s'", itemName);
+	    sqlSafefAppend(where, sizeof(where), " and name = '%s'", itemName);
 	    }
 	sr = hRangeQuery(conn, ct->dbTableName, seqName, start, end,
                      where, &rowOffset);
 	while ((row = sqlNextRow(sr)) != NULL)
 	    {
 	    bedFree(&bed);
 	    bed = bedLoadN(row+rowOffset, ct->fieldCount);
 	    }
 	sqlFreeResult(&sr);
 	hFreeConn(&conn);
 	}
     if (ct->fieldCount < 4)
 	{
 	if (! ct->dbTrack)
 	    {