我有一個查詢,我希望從表中有一個默認值(您可以稱它爲Excel中的vlookup)。我的查詢是這樣的:SQL從表中查詢默認值
select stamdata_sd.id_sd AS id_sd, stamdata_sd.Type_sd
AS Type_sd from stamdata_sd;
我想Type_sd
場查詢是從一個叫type_ty
表中的默認值。事情是這樣的:
select stamdata_sd.id_sd AS id_sd, stamdata_sd.Type_sd default(selected
from a table called type_ty, where the pk id_ty is the higest)
AS Type_sd from stamdata_sd;
所以,當我在查詢中做出新的紀錄,本場Type_sd
是汽車在type_ty
桌上擺滿了最新的實例。
我怎麼能寫這樣的查詢?
有沒有令人信服的理由不在表中存儲正確的值stamdata_sd? –
以在輸入新數據時確定工作流程。那麼用戶不必鍵入該值,並且該值隨時間變化,所以我不能將其設置爲默認值。 – Thomas
ups ...那實際上是錯誤的... – Thomas