无法获取mysql别名的值

时间:2016-07-02 23:39:21

标签: mysql

我有以下代码:

$query = " SELECT distance, outcodepostcodes.lat,     outcodepostcodes.lng     
FROM ( SELECT $table.*, outcodepostcodes.lat, 
outcodepostcodes.lng , outcodepostcodes.lat*3 AS distance 
FROM $table     
LEFT JOIN outcodepostcodes ON UPPER($table.postcode)  =      outcodepostcodes.outcode ) AS x
WHERE $where_no_and AND (hide='0' OR hide IS NULL OR hide='') 
AND distance <= 20 ORDER BY rent $reihenach LIMIT $offset, $rowsPerPage ";

当我这样做时:

$num=mysql_numrows($result);
$i=0;
while ($i < $num) 
{
$id=mysql_result($result,$i,"id");
etc, etc;
$distance=mysql_result($result,$i,"distance"); } 

$ distance为空

任何帮助表示赞赏

0 个答案:

没有答案