1
select
a.time, b.name, c.user_city,
case
when c.user_country='xxxx' and c.user_state in (select cast(state_id as string) from states_list)
then (select d.STATE_NAME from States_LIST d where d.STATE_ID = cast(c.user_state as int))
else c.user_state
end state,
case
when c.user_country in (select cast(COUNTRY_ID as string) from COUNTRIES_LIST)
then (select e.COUNTRY_NAME from COUNTRIES_LIST e where e.COUNTRY_ID = cast(c.user_country as int))
else null
end country, col6, col7, ......
from ......
where.......
:子查詢的黑斑羚case語句在執行上面的查詢在帕拉我得到下面提到的錯誤
不兼容的返回類型數組和exprs「選擇 d.STATE_NAME的字符串從States_LIST d其中d.STATE_ID = CAST(c.user_state 爲INT)「和 'c.user_state'
請幫助!!!!
感謝您的回覆。我確實嘗試加入州表,但仍然無效。我需要的是,用戶在下拉列表中選擇狀態,這些狀態將以字符串格式保存爲狀態代碼,如果是,請拔出狀態名稱,如果用戶狀態輸入,則需要檢查用戶輸入的狀態是否在我的狀態表列表中不是一個有效的值,那麼它應該直接接受用戶輸入的輸入。這是要求,請讓我知道如何在黑斑病中實現這一目標........... –
新增了一個加入如何幫助你的例子。還沒有測試過,所以它可能包含小錯誤和優化可能性 – spijs
是的我已經嘗試添加LIMIT 1,它說'在選擇列表中不支持子查詢' –