这个查询根本就没有按照我想要的方式对结果进行排序:
$sql = mysql_query("select s.*, p.label, p.number
from `sales` as s
left join `pumps` as p on (p.id = s.id_pump)
where s.the_date >= UNIX_TIMESTAMP(DATE_SUB(NOW(), INTERVAL 1 DAY))
order by CAST(s.amount_sale AS int) desc
limit 1") or die(mysql_error());
我收到了一个mysql错误。
答案 0 :(得分:2)
尝试将VARCHAR转换为有符号整数:
$sql = mysql_query("select s.*, p.label, p.number
from `sales` as s
left join `pumps` as p on (p.id = s.id_pump)
where s.the_date >= UNIX_TIMESTAMP(DATE_SUB(NOW(), INTERVAL 1 DAY))
order by CAST(s.amount_sale AS SIGNED) desc
limit 1");