SELECT inventory_single_shop.goods_id,inventory_single_shop.balance,inventory_single_shop.inventory_update_time FROM inventory_single_shop, ( SELECT goods_id, MAX(inventory_update_time) 'time' FROM inventory_single_shop GROUP BY goods_id ) last_time WHERE inventory_single_shop.goods_id = last_time.goods_id AND inventory_single_shop.inventory_update_time = last_time.time;
上面是正确的SQL语句,下面是错误的SQL语句,区别就在于一个给子查询取别名的引号的使用上。
SELECT inventory_single_shop.goods_id,inventory_single_shop.balance,inventory_single_shop.inventory_update_time FROM inventory_single_shop, ( SELECT goods_id, MAX(inventory_update_time) 'time' FROM inventory_single_shop GROUP BY goods_id ) 'last_time' WHERE inventory_single_shop.goods_id = last_time.goods_id AND inventory_single_shop.inventory_update_time = last_time.time;
ORACLE里貌似没有这样的问题
------------正 文 已 结 束, 感 谢 您 的 阅 读 (折雨的天空)--------------------
转载请注明本文标题和链接:《mysql中一个很容易忽略的起别名的语法》
发表评论