为什么不使用此查询(未定义@param为true):
SELECT
c.ID ,
IF((SELECT b.f1 into @param from db.tbl2 as b Where b.f2 = c.f2 AND b.f3 = c.f3),@param,c.off) as 'off'
FROM db.tbl1 as c
答案 0 :(得分:0)
请改用左连接。像这样修改您的查询:
SELECT c.ID ,COALESCE(b.f1,c.off) as 'off'
FROM db.tbl1 as c
LEFT JOIN tbl2 as b ON b.f2 = c.f2 AND b.f3 = c.f3
不要让它变得复杂。