我正在将一些工具转换为使用MySQL到PostgreSQL的工具.有了这个,我遇到了很多问题,但能够找到最重要的一切.我遇到问题的是HEX()和UNHEX().我试着encode(%s, 'hex')和decode(%s, 'hex')它没有真正停止使我有错误,但它仍然似乎没有这样的伎俩.有没有人知道Postgres中这些函数的等价物是什么?
这是旧的MySQL查询:
SELECT HEX(test_table.hash),
title,
user,
reason,
description,
url,
performed,
comment,
authenticated,
status
FROM alerts
JOIN user_responses ON test_table.hash = user_responses.hash
JOIN test_status ON test_table.hash = test_status.hash
WHERE status = %s
Run Code Online (Sandbox Code Playgroud)
以下是PostgreSQL格式的更新查询:
SELECT encode(test_table.hash, 'hex') as hash,
title,
user,
reason,
description,
url,
performed,
comment,
authenticated,
status
FROM test_table
JOIN user_responses ON test_table.hash = user_responses.hash
JOIN test_status ON test_table.hash = test_status.hash
WHERE status = %s
Run Code Online (Sandbox Code Playgroud)
谢谢!