MySQL - 左外连接不返回值

时间:2013-09-11 09:54:15

标签: mysql sql join outer-join

我尝试根据技能代码匹配Hold_Target的值,但无论我做什么,它总是以NULL返回。我在查询中做错了吗?这是我正在使用的。

Select
    ei.TM,
    ei.emp_id,
    ei.DNAME,
    ei.STATUS,
    ei.SHIFT,
    ei.SKILL,
    ct.Target as Hold_Target
From
    mtl_extended_info ei
    Left outer join (
        Select
            ct.Skill,
            ct.Target as Target
        From
            cdl_threshold ct
        Where
            ct.Metric LIKE CONVERT(_utf8 '%Avg Hold Time%' USING latin1) COLLATE latin1_swedish_ci
    ) ct on ct.SKILL = ei.SKILL
Where
    ei.Visible = 1
Group by
    ei.emp_id
Order By
    ei.SM,
    ei.TM,
    ei.DNAME

cdl_threshold table

 Skill   Metric            Target
 WR      Avg Hold Time     100
 CA      Avg Hold Time     100

预期结果

TM                  emp_id    DNAME       STATUS    SHIFT   SKILL   Hold_Target
Peter Parker        842448    Joe Doe     A         FT      CA      100

0 个答案:

没有答案