今天發現了個有趣的問題,order by 與 where子句對別名的支持上,原來存在這樣的區別~~!
1. where 子句不支持別名.
例如: select id, people_name as name form people where name = ‘小明’ 會發生錯誤。
2. order by子句既支持別名,也支持列名
例如:SELECT activity_id,date_format(activity_startTime,'%m-%d') st FROM activity
order by activity_startTime
SELECT activity_id,date_format(activity_startTime,'%m-%d') st FROM activity
order by st
但這兩個語句返回的值是不相同的。