嘿伙计们,我用我出色的 MS SQL 技能编写了这个 MS SQL 脚本,我怎样才能让它在 MySQL 中工作?它在某些字符串函数上失败了:(不太了解 MySQL!
SELECT i.id as ID, e.code as EMPCODE, lower(e.email_address) as EMAIL
from load_incidents i , dim_employee e
WHERE
( (i.involvedemail = e.email_address)
or (replace(lower(e.preferred_name+e.last_name),' ', '') = replace(lower(i.involvedname),' ', ''))
or (replace(lower(e.preferred_name+e.last_name),' ', '') like replace(lower(i.involvedname),' ', '')+'%')
or (replace(lower(e.first_name+e.last_name),' ', '') = replace(lower(i.involvedname),' ', ''))
or (replace(lower(e.first_name+e.last_name),' ', '') like replace(lower(i.involvedname),' ', '')+'%')
or (replace(lower(e.employee_name),' ','') = replace(lower(i.involvedname),' ',''))
)
and charindex(' ',e.first_name) = 0
and (i.involvedemail= 'none available' or i.involvedemail is null or i.involvedemail = '')
UNION
SELECT i.id as ID, e.code as EMPCODE, lower(e.email_address) as EMAIL
from load_incidents i , dim_employee e
WHERE
( (i.involvedemail = e.email_address)
or (replace(lower(e.preferred_name+e.last_name),' ', '') = replace(lower(i.involvedname),' ', ''))
or (replace(lower(e.preferred_name+e.last_name),' ', '') like replace(lower(i.involvedname),' ', '')+'%')
or (replace(lower(left(e.first_name,charindex(' ',e.first_name)-1) + e.last_name),' ', '') = replace(lower(i.involvedname),' ',''))
or (replace(lower(e.employee_name),' ','') = replace(lower(i.involvedname),' ',''))
)
and charindex(' ',e.first_name) > 1
and (i.involvedemail= 'none available' or i.involvedemail is null or i.involvedemail = '')