After aliasing sql field on select, I can not access the result in php

不想你离开。 提交于 2019-12-12 03:47:51

问题


I have a SQL SELECT in which I aliased MIN(A.product_id + 1) to 'min':

$product='SELECT * FROM '.$table.' WHERE product_id > '.(($div_id)*10000).' AND product_id < '.((($div_id+1)*10000)-1).'';  

$select='SELECT MIN(A.product_id + 1) AS min FROM ('.$product.') A LEFT JOIN ('.$product.') B
        ON A.product_id = B.product_id - 1
        WHERE  B.product_id Is NULL';  

this is the result in phpMyAdmin:

But in php I have 'min' => NULL

$result = mysql_query($select, $con);  
$row=mysql_fetch_assoc($result);  

echo $row['min'];  

does not show anything!

来源:https://stackoverflow.com/questions/11267623/after-aliasing-sql-field-on-select-i-can-not-access-the-result-in-php

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!