高手帮我解释一下这个sql语句
select distinct a.fpublish,a.fid,b.fname,d.fid as fauditid,fchangeorder from tblempchange_main a
left join emp_list b on a.femp=b.fid and b.xed=1
left join tblemplive c on a.femp=c.femp
left join tblInstate d 
on charindex('_'+convert(varchar(4),a.fid)+'_', '_'+d.fchangeorder+'_')>0 
and d.xed=0
left join op_list e on a.femp=e.femp and e.xed=1 and e.fauthorization=0
where 
a.xed=1 and a.fpublish in (0)
or charindex('_'+convert(varchar(4),a.fid)+'_',(select '_'+fchangeorder+'_' from tblInstate where fid=5))>0
and charindex('_'+convert(varchar(4),c.fgrade)+'_',(select '_'+fauditgrade+'_' from tblempchange_para))>0
and charindex('_'+convert(varchar(4),e.factor)+'_',(select '_'+fauditactor+'_' from tblempchange_para))>0

解决方案 »

  1.   

    left join
    charindex
    in 就这三个东西啊,感觉很简单,并且这些东西在sql的帮助里面很详细。
    如:
    CHARINDEX
    返回字符串中指定表达式的起始位置。 语法
    CHARINDEX ( expression1 , expression2 [ , start_location ] ) 参数
    expression1一个表达式,其中包含要寻找的字符的次序。expression1 是一个短字符数据类型分类的表达式。expression2一个表达式,通常是一个用于搜索指定序列的列。expression2 属于字符串数据类型分类。start_location在 expression2 中搜索 expression1 时的起始字符位置。如果没有给定 start_location,而是一个负数或零,则将从 expression2 的起始位置开始搜索。
    其他的自己动手,sql的帮助很好,很详细的,不要浪费了,你这样问也找不到什么结果的。