如何在MySQL查询中将布尔值转换为整数。我已经尝试了很多方法,但都没有成功。我只是想将true/false的“value”列分别转换为1和0并插入到“finalvalue”列中。请参见屏幕截图链接。
MySQL查询:
SELECT id, value, finalvalue FROM table;
![](screenshot.png)
SELECT
UNIX_TIMESTAMP(timestamp) as time_sec,
topic as metric,
data as value,
cast(DATA AS SIGNED) as finalvalue
FROM tcl_mqtt_log
WHERE topic = 'jace/home/heatpump/uvlight_ss';