drop function if exists func_get_text_num;
 create function `func_get_text_num`(text varchar(255),begin_num int,end_num int) returns int(10)
 begin
  declare rs int default 0;
  set i=begin_num;
  while (i<=end_num or rs=0) do 
    rs=case when find_in_set(i,text)>0 then 1 else 0 end;
set i=i+1;
  end while;
  return rs;
  end
  
  用法:
  where func_get_text_num(text,3800,4000)=1

解决方案 »

  1.   

    请问一下PHP怎么调用这个过程?
    我用
    $sql = 'select func_get_text_num(zj,3300,3800) from v9_cars_data limit 10';
    $rs = mysql_query($sql, $conn);
    这样的话,变量$rs里没有东西呀
      

  2.   

    我用print_r($rs)显示为空,请问是哪里出错了?我在phpMyAdmin里可以正常执行,结果也是对的,为什么在PHP里自己这样写就不对了呢?
      

  3.   

     $sql=mysql_query("select count(*) as total from tb_fagaiweiregulations",$conn);
       $info=mysql_fetch_array($sql);
    在你前面加上mysql_query函数,显示结果用mysql_fetch_array,$info就能接受到sql的数据了
      

  4.   

    <?php
       $sql=mysql_query("select count(*) as total from tb_fagaiweiregulations",$conn);
       $info=mysql_fetch_array($sql);
       $total=$info[total];
       if($total==0)
       {
         echo "本站暂发信息!";
       }
       else
       {
       ?>