sql判断语句
2014-04-09 18:22
267 查看
方法一:
<if test="null != orderType and 0 == orderType">
order by amountTimes desc
</if>
<if test="null != orderType and 1 == orderType">
order by amountTimes asc
</if>
<if test="null != orderType and 2 == orderType">
order by amountUsedTime desc
</if>
<if test="null != orderType and 3 == orderType">
order by amountUsedTime asc
</if>
<if test="null != orderType and 4 == orderType">
order by amountUsedTime/amountTimes desc
</if>
<if test="null != orderType and 5 == orderType">
order by amountUsedTime/amountTimes asc
</if>
方法二:
case
when timage.original_url is null then '/images/no_picture.gif'
when timage.original_url is null then '/images/no_picture.gif'
when timage.original_url is null then '/images/no_picture.gif'
else timage.original_url
end as tourgallery
<if test="null != orderType and 0 == orderType">
order by amountTimes desc
</if>
<if test="null != orderType and 1 == orderType">
order by amountTimes asc
</if>
<if test="null != orderType and 2 == orderType">
order by amountUsedTime desc
</if>
<if test="null != orderType and 3 == orderType">
order by amountUsedTime asc
</if>
<if test="null != orderType and 4 == orderType">
order by amountUsedTime/amountTimes desc
</if>
<if test="null != orderType and 5 == orderType">
order by amountUsedTime/amountTimes asc
</if>
方法二:
case
when timage.original_url is null then '/images/no_picture.gif'
when timage.original_url is null then '/images/no_picture.gif'
when timage.original_url is null then '/images/no_picture.gif'
else timage.original_url
end as tourgallery
相关文章推荐
- 类似微博判断用户关系的sql语句
- SQL语句大全:侧重创建、判断对象是否存在相关语句
- SQL查询和判断语句
- SQL语句Where中使用别名作为判断条件
- 2012-05-25 19:09 sql语句里的is null判断在thinkphp里的写法
- 小随笔 SQL语句中的条件判断CASE
- SQL判断语句用法和多表查询
- 具有异常判断的数据库事务Sql语句
- pl/sql常用判断语句
- SQL常用判断检测语句
- sql语句拼装,需要if判断时一个小技巧
- 页面Sql语句 查询根据判断值是否存在拼接查询条件
- SQL 常用判断语句
- 在ASP中判断SQL语句是否执行成功
- sql语句也可以写类似于if的判断
- SQL 语句判断记录是否存在(最简洁简单性能最优)
- 常用判断重复记录的SQL语句
- SQL利用Case When Then多条件判断SQL 语句
- 类似微博判断用户关系的sql语句
- 判断SQL 中SELECT 语句所影响的行