我在MYSQL中执行此查询时遇到错误。你能帮我解决一下这个问题。这是查询。
IF ('"+ @[User::CrMgName] +"' IS NULL)
THEN
Update companies
Set crm_id = '"+ @[User::crm_guid] +"'
Where TRIM(LOWER(company_directory_name)) = '"+ @[User::EquityStoryId] +"'
ELSE
Update companies
Set cr_manager = '"+ @[User::CrMgName] +"',
crm_id = '"+ @[User::crm_guid] +"'
Where TRIM(LOWER(company_directory_name)) = '"+ @[User::EquityStoryId] +"'
END IF
答案 0 :(得分:0)
评论之后,如果在脚本中使用IF语句表示该问题。
所以,解决方案是两个:
IF
语句替换为CASE
语句对于解决方案2.试试这个:
UPDATE companies
SET crm_id =
CASE
WHEN @[User::CrMgName] IS NULL THEN '"+ @[User::crm_guid] +"'
ELSE'"+ @[User::crm_guid] +"'
END,
cr_manager =
CASE
WHEN @[User::CrMgName] IS NULL THEN cr_manager
ELSE '"+ @[User::CrMgName] +"'
END
WHERE TRIM(LOWER(company_directory_name)) = '"+ @[User::EquityStoryId] +"'