0
這段代碼有什麼問題?oracle中的case sql
select emp_id, emp_name
from emp
where case when :emp.designation_id = '008' then designation_id = '003'
這段代碼有什麼問題?oracle中的case sql
select emp_id, emp_name
from emp
where case when :emp.designation_id = '008' then designation_id = '003'
case
是一個返回值的表達式。並且case
表達以end
結束。而一個case
表達式返回一個有效的類型。
也許你打算:
select emp_id, emp_name
from emp
where designation_id = (case when :emp.designation_id = '008' then designation_id = '003' end);
表達更簡單的方法這邏輯,而case
是:
where :emp.designation_id = '008' and designation_id = '003'
但你可能真的打算:
where (:emp.designation_id = '008' and designation_id = '003') or
(:emp.designation_id <> '008' and designation_id = :emp.designation_id)
謝謝...... Gordon Linoff其工作。 –
看看在這個問題https://stackoverflow.com/questions/24249323/us ing-case-inside-where-clause – kzharas210