将此MySQL查询转换为PyGreSQL [英] Translate this MySQL query to PyGreSQL
本文介绍了将此MySQL查询转换为PyGreSQL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在开发一个使用mysql函数XOR(^)和BIT_COUNT()的Ruby应用。但是,我现在需要在运行PyGreSQL的Heroku上运行该应用程序。
I'm working on a Ruby app which uses the mysql functions XOR (^) and BIT_COUNT(). However I now need to run the app on Heroku, which runs PyGreSQL.
我找不到任何可以帮助我的PyGreSQL文档。
I can't find any documentation for the bits of PyGreSQL that can help me.
那么任何人都可以翻译此mysql查询,以便在pygresql数据库上执行时可以正常工作吗?
So can anyone translate this mysql query so that it would work when executed on a pygresql database?
SELECT * FROM "photos" WHERE BIT_COUNT(phash ^ 2061756291569501157) <= 15
pygresql给我错误
pygresql gives me the error
ERROR: operator does not exist: text ^ bigint
谢谢。
推荐答案
SELECT *
FROM photos
WHERE (
SELECT SUM(((phash::bigint # 2061756291569501157) >> bit) & 1)
FROM generate_series(0, 63) bit
) <= 15
这篇关于将此MySQL查询转换为PyGreSQL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文