我有這個疑問,在甲骨文工作,但我想它轉換爲用,因爲我與Visual Studio有一些問題合併。的Oracle SQL使用合併
SELECT *
FROM a Left Join b on b.institution_code=a.institution_code
WHERE
(upper(a.Login_Name)=UPPER('%' || :Login_Name || '%') OR :Login_Name IS NULL)
AND (upper(a.Display_Name) Like UPPER('%' || :Display_Name || '%') OR :Display_Name IS NULL)
AND (upper(a.Email_Address)=UPPER(:Email_Address) OR :Email_Address IS NULL)
AND ((a.institution_code=:institution_code) OR :institution_code IS NULL)
AND (upper(b.institution_desc) Like UPPER('%' || :institution_desc || '%') OR :institution_desc IS NULL)
這工作
WHERE
Upper(a.Display_Name) LIKE Upper('%' || COALESCE(:Display_Name,a.Display_Name) || '%')
AND upper(a.Login_Name)=Upper(COALESCE(:Login_Name,a.Login_Name))
AND upper(a.Email_Address)=Upper(COALESCE(:Email_Address,a.Email_Address))
但是當我嘗試到institution_code和institution_desc場使用COALESCE我沒有得到來自任何查詢結果轉換。
當我添加這些線路目前還沒有結果
AND a.institution_code=COALESCE(:institution_code,a.institution_code)
AND (Upper(b.institution_desc) LIKE Upper('%' || COALESCE(:institution_desc,b.institution_desc) || '%'))
遺憾,但這並沒有工作 – 2009-08-24 20:40:14