Is it possible to hash the entire result in mysql?

Is it possible to apply a hash function to the entire resultset in mysql.

I know how the hash values ​​in each row of the result set

eg. SELECT md5('something')

However, I will say that I have a request like

SELECT * FROM `some_table`

      

And the result set contains many rows, is it possible to hash the entire result set into one value?

It should be clear to me that I don't want a hash for every line. I want one hash of the entire result set.

i.e. one has the whole set.

edited to make the requirement clearer.

+3


source to share


3 answers


combine CONCAT()

and GROUP_CONCAT()

:



SELECT MD5(GROUP_CONCAT(CONCAT(col1,col2,...))), 1 as g
  FROM some_table GROUP BY g;

      

+5


source


You can concatenate all columns together and use the result to md5()

:



select md5(concat(col1, col2, . . . coln)) 
from some_table;

      

+1


source


You will need to create a concatenated row of all columns and then apply the hash.

SELECT MD5(CONCATE(COL1,COL2,COL3...COLn))

      

+1


source







All Articles