我正在尝试根据颜色与样本的距离来排序颜色列表。 公式为:
d = sqrt( (sR-R)^2 - (sG-G)^2 - (sB-B)^2 )
我正在测试的示例是:sRGB(255,0,0)。
这是我的代码:
SELECT color.id, color.red, color.green, color.blue, brand.name,
SQRT(POW((255-color.red),2)+POW((0-color.green),2)+POW((0-color.blue),2)) AS d
FROM color, brand
WHERE color.brand = brand.id
ORDER BY d
LIMIT 20 OFFSET 0
我不断收到错误:
#2014 - Commands out of sync; you can't run this command now
不确定发生了什么。
额外信息:
- MySQL 5.6.22
- 在 phpMyAdmin 4.0.10.7 中运行代码
最佳答案
摆脱“数据截断:BIGINT UNSIGNED 值超出范围”
... POW(0-CAST(color.green AS SIGNED), 2) ...
“#2014 - 命令不同步;您现在无法运行此命令”来自构造不正确的存储过程。让我们看看整个 SP。
关于MySQL RGB 比较错误 - 命令不同步,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28651675/