简体   繁体   English

检索特定的行数据

[英]Retrieve particular row data

<code>
select t.range as [Type], count(*) as [Value]
from (select case  
      when answer_count between 0 and 5 then 'PCS'
      when answer_count between 5 and 10 then 'PRINTER'
      else 'KEYBOARD' end as range
      from points where type='product_quiz') t  
group by t.range
</code>
Output is:
---------------------
Type     |     Value
---------------------
PCS            129195
PRINTER        121327
OTHERS         236548


I want to echo only for the printer value using PHP.
For example I want the result like this:

    echo $printer = '121327';

Try this: 尝试这个:

$query = mysql_query("select t.range as [Type], count(*) as [Value]
from (select case  
  when answer_count between 0 and 5 then 'PCS'
  when answer_count between 5 and 10 then 'PRINTER'
  else 'KEYBOARD' end as range
  from points where type='product_quiz') t  
  group by t.range");
while($row = mysql_fetch_assoc($query))
{
  if($row['type'] == 'PRINTER'){
    echo $printer = $row['value'];
  }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM