1
我嘗試在我在MySQL中使用的h2db中測試我的查詢,但我得到了一個異常,未找到我的列「名稱」。在h2db中的ORDER BY子句中使用別名
我的查詢看起來是這樣的:
select t1.name as name, t1.code
from table1 t1
where t1.total > 50
union
select t2.name as name, t2.code
from table2 t2
where t2.total < 50
order by UPPER(name)
我有例外
產生的原因:org.h2.jdbc.JdbcSQLException:列 「名稱」 未找到;
如何在h2db中運行這樣的查詢?
在此先感謝。
你嘗試排序通過t1.name,它有什麼區別? –
你能發佈完整的錯誤信息和堆棧跟蹤嗎?我無法用最近版本的H2重現這個問題。上面的查詢適用於我。也許你正在使用舊版本的H2,或者你正在使用不同的查詢? –
對不起。我按順序錯過了一個函數。我使用「通過UPPER(名稱)」 – saltex