我需要进行更新查询,从我的Google日历列中制作md5哈希值。这是我的问题:
UPDATE `ea_appointments` SET `hash` = MD5(`id_google_calendar`)
这可以做到这样吗?:
Table: ea_appointments
id_google_calendar Hash
e5e3were760lkj792c7t5vm61bvk_20160729T200000Z d5f9f4ef02e438d49c8bf39cd4b4118d
答案 0 :(得分:0)
是的,它会起作用。 你可以通过以下方式松散检查:
select md5('test');
结果:
+----------------------------------+
| md5('test') |
+----------------------------------+
| 098f6bcd4621d373cade4e832627b4f6 |
+----------------------------------+
或者:
select md5('e5e3were760lkj792c7t5vm61bvk_20160729T200000Z');
结果:
+------------------------------------------------------+
| md5('e5e3were760lkj792c7t5vm61bvk_20160729T200000Z') |
+------------------------------------------------------+
| 06b5a13d9a7b0ed26ab1406434954972 |
+------------------------------------------------------+
或者:
create table t(id_google_calendar varchar(100), hash varchar(100));
insert into t values ('e5e3were760lkj792c7t5vm61bvk_20160729T200000Z', '');
update t set Hash = md5(id_google_calendar);
select * from t;
结果:
+-----------------------------------------------+----------------------------------+
| id_google_calendar | hash |
+-----------------------------------------------+----------------------------------+
| e5e3were760lkj792c7t5vm61bvk_20160729T200000Z | 06b5a13d9a7b0ed26ab1406434954972 |
+-----------------------------------------------+----------------------------------+
答案 1 :(得分:0)
我认为它会起作用。
另外我建议你先测试一下。 您可以使用以下方法测试查询: