mySQL: get hash value for each row?

前端 未结 5 1839
长发绾君心
长发绾君心 2021-01-04 07:00

Currently I\'m manually creating a string where I concatenate all the values in each row in my table. I\'m hashing this string for each row to get a hash value for the curre

5条回答
  •  谎友^
    谎友^ (楼主)
    2021-01-04 07:52

    Well I made a little script that could do excactly what you want, and maybe what others want... so here it goes...for PHP that is... first you have to make a list of columns of the table, then you make a "case when" statement for each column based on their type and put that in the concat_ws statement and then you hash it with sha1...i've used this method on very large tables (600000+ records) and the speed is quite good when selecting all records. also I think that it is faster to concat the required data in a concat_ws and explode it in php or whatever you are using, but that is just a hunch...

    
    

提交回复
热议问题