Results 1 to 10 of 10
Feb 3, 2013, 22:13 #1
- Join Date
- Jan 2012
- 0 Post(s)
- 0 Thread(s)
Need a Selective GROUP BY in My Query
Is there a way to write a GROUP BY command that doesn't affect certain rows? I've discovered that my information displays best if I group the values in the field "Symbol" (GROUP BY G3.Symbol), where Symbol is simply the name of a state symbol (e.g. robin, moose, brook trout, etc.).
However, it doesn't work for symbols that have no names - flags and state seals. Neither one has a value in the Symbol field, and therefore they're treated as equal values, which means only the first one (flag) displays.
So is there some way to say GROUP BY G3.Symbol...unless G2.DesigGroup = 'Vex'?
$res = mysql_query ("SELECT G2.N, G2.IDArea GID, G2.URL, G2.PostURL, G2.Title, G2.MyKind2, G2.DesigGen, G2.DesigGroup, G3.N, G3.URL, G3.Symbol, G3.Desig, G3.Latin, G3.Date FROM gs2 G2 LEFT JOIN gs3 AS G3 ON G3.URL = G2.URL WHERE G2.IDArea = '$MyID' AND G2.MyKind2 = 3 GROUP BY G3.Symbol ORDER BY G2.N") or die (mysql_error());