用PHP代码,对MYSQL数据表中某字段特定值,求对应字段最大值
MYSQL数据库中,数据表:green,字段:a,b,c-------------------------abc2223cc1111aa3331bb1112cc1111c...
MYSQL数据库中,数据表:green,字段:a,b,c ------------------------- a b c 222 3 cc 111 1 aa 333 1 bb 111 2 cc 111 1 cc 444 2 aa 111 1 bb 333 3 dd ------------------------- 若字段c等于aa,$c=10,若字段c等于bb,$c=20,若字段c等于cc,$c=30,若字段d等于dd,$d=40, 我写了如下的语句: $green = "SELECT * FROM ". GREEN . " "; if($green->fields['c']=='aa') {$c=10;} elseif($green->fields['c']=='bb') {$c=20;} elseif($green->fields['c']=='cc') {$c=30;} elseif($green->fields['c']=='dd') {$d=40;} 我要通过PHP代码在网页上显示一个值,这个值为: 字段a等于111,且字段b等于1,显示$c的最大值$c_max。 对于上述的MYSQL数据表,这个$c_max就应等于30, 但不知道如何写这个PHP代码呢?请高手帮忙,谢谢。
展开
1个回答
展开全部
说实话,不明白你要干啥。
$green
=
"SELECT
*
FROM
".
GREEN
.
"
";
if($green->fields['c']=='aa')
{$c=10;}
elseif($green->fields['c']=='bb')
{$c=20;}
elseif($green->fields['c']=='cc')
{$c=30;}
elseif($green->fields['c']=='dd')
{$d=40;}
elseif($green->fields['a']=='111'
and
$green->fields['b']=='1'){$c_max=30;}
这样子?
$green
=
"SELECT
*
FROM
".
GREEN
.
"
";
if($green->fields['c']=='aa')
{$c=10;}
elseif($green->fields['c']=='bb')
{$c=20;}
elseif($green->fields['c']=='cc')
{$c=30;}
elseif($green->fields['c']=='dd')
{$d=40;}
elseif($green->fields['a']=='111'
and
$green->fields['b']=='1'){$c_max=30;}
这样子?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询