SQL语句嵌套if

在存储过程中我要实现一个IF的嵌套语句查询,类似与
if()
{
    if()
     {
        ......
     }
     else
     {
        ......
     }
}
else
{
    ......
}
请问这样的SQL语句要怎么写啊?

create procedure `test2`
(
IN cusername <a href="https://www.baidu.com/s?wd=VARCHAR&tn=44039180_cpr&fenlei=mv6quAkxTZn0IZRqIHckPjm4nH00T1dWPj6knWw9PvDzPAc4nH0z0ZwV5Hcvrjm3rH6sPfKWUMw85HfYnjn4nH6sgvPsT6K1TL0qnfK1TL0z5HD0IgF_5y9YIZ0lQzqlpA-bmyt8mh7GuZR8mvqVQL7dugPYpyq8Q1D3rjnYnWbYnHDzPjmzrHTkPj6" target="_blank" class="baidu-highlight">VARCHAR</a>(50),
IN cpassword <a href="https://www.baidu.com/s?wd=VARCHAR&tn=44039180_cpr&fenlei=mv6quAkxTZn0IZRqIHckPjm4nH00T1dWPj6knWw9PvDzPAc4nH0z0ZwV5Hcvrjm3rH6sPfKWUMw85HfYnjn4nH6sgvPsT6K1TL0qnfK1TL0z5HD0IgF_5y9YIZ0lQzqlpA-bmyt8mh7GuZR8mvqVQL7dugPYpyq8Q1D3rjnYnWbYnHDzPjmzrHTkPj6" target="_blank" class="baidu-highlight">VARCHAR</a>(50),
IN clastloginio <a href="https://www.baidu.com/s?wd=VARCHAR&tn=44039180_cpr&fenlei=mv6quAkxTZn0IZRqIHckPjm4nH00T1dWPj6knWw9PvDzPAc4nH0z0ZwV5Hcvrjm3rH6sPfKWUMw85HfYnjn4nH6sgvPsT6K1TL0qnfK1TL0z5HD0IgF_5y9YIZ0lQzqlpA-bmyt8mh7GuZR8mvqVQL7dugPYpyq8Q1D3rjnYnWbYnHDzPjmzrHTkPj6" target="_blank" class="baidu-highlight">VARCHAR</a>(50)
)
BEGIN  
    if exists(select from mt_userlogin where username=cusername) then
--    if exists(select 1) then
        if(1=1) THEN
            select 1;
        <a href="https://www.baidu.com/s?wd=ELSE&tn=44039180_cpr&fenlei=mv6quAkxTZn0IZRqIHckPjm4nH00T1dWPj6knWw9PvDzPAc4nH0z0ZwV5Hcvrjm3rH6sPfKWUMw85HfYnjn4nH6sgvPsT6K1TL0qnfK1TL0z5HD0IgF_5y9YIZ0lQzqlpA-bmyt8mh7GuZR8mvqVQL7dugPYpyq8Q1D3rjnYnWbYnHDzPjmzrHTkPj6" target="_blank" class="baidu-highlight">ELSE</a>
            select 2;
        end if;
    <a href="https://www.baidu.com/s?wd=ELSE&tn=44039180_cpr&fenlei=mv6quAkxTZn0IZRqIHckPjm4nH00T1dWPj6knWw9PvDzPAc4nH0z0ZwV5Hcvrjm3rH6sPfKWUMw85HfYnjn4nH6sgvPsT6K1TL0qnfK1TL0z5HD0IgF_5y9YIZ0lQzqlpA-bmyt8mh7GuZR8mvqVQL7dugPYpyq8Q1D3rjnYnWbYnHDzPjmzrHTkPj6" target="_blank" class="baidu-highlight">ELSE</a>  
        select -7,'Username not found';
    end if;
end;
上一篇:Quartz集群


下一篇:hihocoder-1407 后缀数组二·重复旋律2 不重合 最少重复K次