Debian で MySQL 5.1.66-0+squeeze1-log を使用すると、理解できない GROUP BY の結果が得られます。
GROUP BY の場合data
、等しくないdata
値が結合されますが、これは意味がありません。同じ列 SHA1( ) のハッシュ値を GROUP BY するとdata
、すべてが正常に機能し、等しい値のみdata
がグループに結合されます。
ここで何が起こっているのですか?GROUP BY は、列の最初の x 文字のみを考慮しているようです。そうでない場合、他になぜこれが起こるのでしょうか? 多分それは私の脳のねじれですか?
data
編集 1: (json でエンコードされたレガシー - 私がもっとばかだったときの値の例;) ):
{"a":[{"val":{"tcn":{"1980":"1","1981":"1","1982":"1","1983":"1","1984":"1","1985":"1","1986":"1","1987":"1","1988":"1","1989":"1","1990":"1","1991":"1","1992":"1","1993":"1","1994":"1","1995":"1","1996":"1","1997":"1","1998":"1","1999":"1","2000":"1","2001":"1","2002":"1","2003":"1","2004":"1","2005":"1","2006":"1","2007":"1","2008":"1","2009":"1","2010":"1"},"sic":{"1980":"1","1981":"1","1982":"1","1983":"1","1984":"1","1985":"1","1986":"1","1987":"1","1988":"1","1989":"1","1990":"1","1991":"1","1992":"1","1993":"1","1994":"1","1995":"1","1996":"1","1997":"1","1998":"1","1999":"1","2000":"1","2001":"1","2002":"1","2003":"1","2004":"1","2005":"1","2006":"1","2007":"1","2008":"1","2009":"1","2010":"1"}}}],"b":[{"val":{"tcn":{"1980":"1","1981":"1","1982":"1","1983":"1","1984":"1","1985":"1","1986":"1","1987":"1","1988":"1","1989":"1","1990":"1","1991":"1","1992":"1","1993":"1","1994":"1","1995":"1","1996":"1","1997":"1","1998":"1","1999":"1","2000":"1","2001":"1","2002":"1","2003":"1","2004":"1","2005":"1","2006":"1","2007":"1","2008":"1","2009":"1","2010":"1"},"sic":{"1980":"1","1981":"1","1982":"1","1983":"1","1984":"1","1985":"1","1986":"1","1987":"1","1988":"1","1989":"1","1990":"1","1991":"1","1992":"1","1993":"1","1994":"1","1995":"1","1996":"1","1997":"1","1998":"1","1999":"1","2000":"1","2001":"1","2002":"1","2003":"1","2004":"1","2005":"1","2006":"1","2007":"1","2008":"1","2009":"1","2010":"1"}}}],"0":[{"val":{"com":{"able":"2"}},"str":{"com":{"comm":"According","src":{"1":{"name":"law 256","articles":"B2\/2.11","links":"","type":""},"2":{"name":"law 298","articles":"B.19\/2.3","links":"","type":""}}}}}]}
EDIT 2:コードを省略して申し訳ありません。コードを短く簡単にすると思いました。明らかに逆ですよね…
SELECT
GROUP_CONCAT(resid) AS ids
,data
FROM resdata
GROUP BY data
対。
SELECT
GROUP_CONCAT(resid) AS ids
,CAST(SHA1(data) AS CHAR(40)) AS hash
,data
FROM resdata
GROUP BY hash