本文介紹了Where 子句中的未知列的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!
問題描述
我有一個簡單的查詢:
SELECT u_name AS user_name FROM users WHERE user_name = "john";
我在 where 子句中得到 Unknown Column 'user_name'
.即使在 select 'u_name as user_name'
之后,我也不能在語句的其他部分引用 'user_name'
嗎?
I get Unknown Column 'user_name' in where clause
. Can I not refer to 'user_name'
in other parts of the statement even after select 'u_name as user_name'
?
推薦答案
SQL 是從右到左向后評估的.所以 where 子句在 select 子句之前被解析和評估.因此,尚未發(fā)生 u_name 到 user_name 的別名.
SQL is evaluated backwards, from right to left. So the where clause is parsed and evaluate prior to the select clause. Because of this the aliasing of u_name to user_name has not yet occurred.
這篇關(guān)于Where 子句中的未知列的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!
【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請聯(lián)系我們刪除處理,感謝您的支持!