mysql - Selecting data where a column is maximum -
mysql - Selecting data where a column is maximum -
i have mysql table below.
id x y z 1 1 1 1 2 7 4 2 2 9 4 3 3 2 3 1 4 2 2 1 4 2 2 2 5 3 3 1
i want select x ( id=2 , y=4 , z maximum). have code cant understand add together max function.
$check_x=mysql_query("select x hamdun_soft id='2' , y='4'");
please help me mysql.
there right variant if need only 1 x maximum z
select x hamdun_soft id = '2' , y= '4' order z desc limit 1
and variant subquery if there may not 1 x maximum z.
select x hamdun_soft id = '2' , y = '4' , z = (select max(z) hamdun_soft id = '2' , y = '4')
p. s.
and don't forget mysql_*
family of function deprecated now. can utilize mysqli_*
or pdo
.
mysql
Comments
Post a Comment