MySQL:获取每一行的哈希值? [英] mySQL: get hash value for each row?

查看:1337
本文介绍了MySQL:获取每一行的哈希值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当前,我正在手动创建一个字符串,在其中将表中每一行的所有值连接在一起.我正在为每行哈希该字符串,以获取该行的当前值(/状态)的哈希值,稍后将用于确定该行是否已更改.

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 current values (/status) of the row, which I'm later is using to determine if the row has changed.

不是手动执行此操作,而是通过mySQL的内置方法来为每一行获取唯一的哈希值吗?

Instead of doing this manually, is there an build-in way i mySQL to get a unique hash value for each row?

推荐答案

您可以做类似的事情

SELECT MD5(concat(field1, field2, field3, ...)) AS rowhash

但是您无法摆脱列出想要的字段的原因,因为concat(*)不是一个选项(语法错误).

but you can't get away from listing which fields you want, as concat(*) is not an option (syntax error).

这篇关于MySQL:获取每一行的哈希值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆