只是想知道,是否有原因,爲什麼下面的代碼不起作用?我試圖更新2列值,如果他們達到多個標準,但我得到一個錯誤,說'關鍵字附近的錯誤語法'如果'和'總'附近的語法不正確。任何幫助非常感謝!if else語句設置條件(SQL)
update [dbo].[wages table]
IF([criteria1]='AA1' and [criteria2]='50yrs and below' and [criteria3]= 'X<=50')
set [Total ] = '0', [Employee ]='0' else
if ([criteria1]='AA1' and [criteria2]='50yrs and below' and [criteria3]= 'X<=50')
set [Total ] = '10', [Employee ]='10' else
if ([criteria1]='AA1' and [criteria2]='50yrs and below' and [criteria3]= 'X<=50')
set [Total ] = '20', [Employee ]='20' else
if ([criteria1]='AA1' and [criteria2]='50yrs and below' and [criteria3]= 'X<=50')
set [Total ] = '30', [Employee ]='30' else
set [Total ] = 'NULL', [Employee ]='NULL'
是條件'如果([標準1] = 'AA1' 和[criteria2] = '50yrs和下方的' 和[criteria3] = 'X <= 50')'相同對全部? – 2015-03-02 09:44:27
您使用的是哪種數據庫平臺? SQL Server,Oracle等。 – 2015-03-02 09:46:05
使用CASE(表達式)。 – jarlh 2015-03-02 09:47:21