我想根据field_value
表中的字段是否为NULL
.
这是我的有效查询:
SELECT field_id, (
SELECT field_value
FROM employee_field_info
WHERE employee_id = '1'
AND field_id = persona_fields.field_id
) AS field_value, (
SELECT field
FROM FIELDS WHERE id = persona_fields.field_id
) AS field_name
FROM persona_fields
WHERE persona_id = '1'
field_value
如果是,我想要做的是添加一个 tinyint(用于布尔)列NULL
。
我试过这个:
SELECT field_id, (
SELECT field_value
FROM employee_field_info
WHERE employee_id = '1'
AND field_id = persona_fields.field_id
) AS field_value, (
SELECT field
FROM FIELDS WHERE id = persona_fields.field_id
) AS field_name,
IF(field_value IS NULL, "0","1") AS value_bool
FROM persona_fields
WHERE persona_id = '1'
但这只是在'字段列表'中出现“未知列'field_value'。无论如何我可以完成我想做的事情,还是我很不走运?