Oracle:更新多行同列不同值

遇到个问题……

这几天遇到个问题,就是在访问后台的时候被强制使用了SSL,所以导致上不了后台.我是如下这样解决的:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
// 下面这个函数在:[wp-includes/functions.php]中
/**
 * Whether to force SSL used for the Administration Screens.
 *
 * @since 2.6.0
 *
 * @staticvar bool $forced
 *
 * @param string|bool $force Optional. Whether to force SSL in admin screens. Default null.
 * @return bool True if forced, false if not forced.
 */
function force_ssl_admin( $force = null ) {
        static $forced = false;

        if ( !is_null( $force ) ) {
                $old_forced = $forced;
                $forced = $force;
                return $old_forced;
        }
        return false;
        //return $forced; 注释掉这一行,然上面直接添加一句 return false;即可.
}

只能这样临时先访问了…

Oracle LOGO
image-2460

关于题目的问题

其实对于题目,说起来也很简单了,大概是这样一个场景:

比如我们正在构建一个信息系统,每个用户每个月有一次抽奖机会,假设我们需要给每次最新的抽奖记录一个标记为1,那么之前的就要标识为0.

好了,上面这个场景就是这个问题.一句话就是:更新某个用户最新一条记录为1,之前的为0.

解决了.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
update users_activity
            set lastupdate=(
            case
            when id=#{id} then 1
            when id!=#{id} then 0
            else 0
            end
            ) where userid=#{userid}



--  
update users_activity
            set 要更新的字段=(
            case
            when id=最新记录ID then 1
            when id!=最新记录ID then 0
            else 0
            end
            ) where userid=用户ID

如上,问题解决.

《Oracle:更新多行同列不同值》上有2条评论

回复 蒂欧娜 取消回复

您的电子邮箱地址不会被公开。 必填项已用*标注

*

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据