同一个表上的多个连接

时间:2015-05-13 00:45:55

标签: mysql sql oracle sqlite join

我有以下表格:

  $.getJSON("/static/json/data.json", function(data) {
        $.each(data.features, function(key, val){
           $.each(val.geometry, function(i, g){
                if (g ==="Point") {
                    x = 1;
                } else{
                    var myLatlng = new google.maps.LatLng(g[1], g[0]);
                    var marker = new google.maps.Marker({
                        position: myLatlng,
                        map: map
                    });
                }
            })
        });
    });

我需要从Technician Tech_ID,First_Name,Last_Name RT_QUEUE_Delta Tech_ID, RT_Complete` (references a `Tech_ID` in `Technician`). RT_Queue_Delta中的一行获取数据,但在我的输出中,我需要将RT_Completed = ??First_Name e与{{{}}相关联1}}和Last_nam

我可以匹配一个,但我不知道如何匹配两者。我试过了:

Tech_id

1 个答案:

答案 0 :(得分:1)

您可以多次加入Technician表:

select d.tech_id, t.first_name, t.last_name, 
       d.rt_completed as completed_id, 
       t2.first_name as completed_first_name, 
       t2.last_name as completed_last_name
from RT_QUEUE_Delta d
    join Technician t on d.tech_id = t.tech_id
    join Technician t2 on d.RT_Completed = t2.tech_id