我有列位置,但我需要根据另一列的值返回此列 下面是MYSQL SELECT QUERY:
if(block.block_id IS NOT NULL)
{
location.location = 'BLOCKED'
}elseif(nvocc.nvocc_id is not null AND nvocc.nvocc_status = 'IN') {
location.location = 'NVOCC'
}else {
location.location = location.location
}
我对案件条件感到畏惧,但显示错误
CASE
WHEN block.block_id IS NOT NULL THEN "BLOCKED"
WHEN ((nvocc.nvocc_id IS NOT NULL) AND (nvocc.nvocc_status='IN')) THEN "NVOCC"
ELSE location.location
END as location
以上查询返回任何内容并且无法正常工作 请有人帮我解决这个问题。
答案 0 :(得分:1)
尝试使用括号将条件块与控制流程块明确分开:
CASE
WHEN block.block_id IS NOT NULL THEN "BLOCKED"
WHEN ((nvocc.nvocc_id IS NOT NULL) AND (nvocc.nvocc_status='IN')) THEN "NVOCC"
ELSE location.location
END
尝试简化查询直到它工作,然后逐步添加条件。
请提供您的错误,这很难猜到。