mysql 问题, 
20选7, 开奖结果为:05|07|10|11|14|15|17
表结构为一个字段存着各人的猜得结果, 格式同上.如何一次性比对出, 各人赢了几个数字?求:mysql语句意向: 
$sql = "update table set win=4 where (字段 REGEXP $result)=4";
$sql = "update table set win=5 where (字段 REGEXP $result)=5";
$sql = "update table set win=6 where (字段 REGEXP $result)=6";
$sql = "update table set win=7 where (字段 REGEXP $result)=7";这一语句如何写?
谢谢赐教.

解决方案 »

  1.   

    应该在PHP中处理匹配结果。
    在mysql中除非数字全中,否则很难一次性对比出结果。
      

  2.   

    php中处理比较好。不要过度依赖数据库
      

  3.   

    //假设字段为a
    $str="05,07,10,11,14,15,17";
    $op ="'";
    $str = $op.$str.$op;
    $sql = "update table set win=4 where find_in_set(a,$str)" ;
      

  4.   

    php中处理比较好。不要过度依赖数据库
    谢谢, 但是数据多了后, 数据集会跑不过来, 分页的话, 就麻烦了
    ===============================
    谢谢yueliangdao0608启发, 现在偶想到了只有一个复杂得方法, 
    用find_in_set('一个数字', 字段名)
    $sql = "update table set win=4 where (find_in_set('第1位数字',字段名)=1 and find_in_set('第2位数字',字段名)=2 and find_in_set('第3位数字',字段名)=3 and and find_in_set('第4位数字',字段名)=4) or (...) or ..." ; (p74个)
    ==============
    我认为能一次性行得通, 上面就是一种比较复杂的方法. 但不是好得方法.
    希望大家能继续赐教.谢谢.