我使用了select in if例如:
select IF (LEAVETYPE = 1 , (select test1,test2 from TableName),(select test3,test4 from TableName where id = 2)
FROM TableName
I Wanne在IF中使用了选择
答案 0 :(得分:2)
这个问题已经被问到了。你可以在这里找到答案:https://stackoverflow.com/a/63480/8713889
你应该使用CASE。来自mysql doc的示例:
import java.util.*;
public class BreakingMaps{
public static void main(String[] args){
int count = Integer.MAX_VALUE>>5;
System.out.println(count + " objects tested");
HashMap<Long, String> set = new HashMap<>(count);
for(long i = 0; i<count; i++){
Long l = i;
set.put(l, l.toString());
}
Random r = new Random();
for(int i = 0; i<1000; i++){
long k = r.nextInt()%count;
k = k<0?-k:k;
System.out.println(set.get(k));
}
}
}