Simple question: outer join / where

Jul 17, 2013 at 1:11 PM
Edited Jul 17, 2013 at 5:54 PM
Hi. Can somebody explain how to outer join? (A bit like this, but more simple. "Left outer self join / Select with index" example was good, but 'selfjoin' confused me??)

EG:

Arrays:
Places:
[id=0, title="london"],
[id=1, title="england"],
[id=2, title="camden"],
[id=3, title="america"]

Places_Places:
[parentId=1, childId=0],
[parentId=0, childId=2]
In SQL it would be:
SELECT * FROM Places
LEFT OUTER JOIN Places_Places 
ON Places.id = Places_Places.childId 
WHERE Places_Places.childId IS null
My best linqjs attempt so far:
nodes = Enumerable.From(Places)
        .Join(Places_Places, "$.id", "$.parentId", function (p, p_p){return p});
Thanks
Jul 18, 2013 at 10:29 AM
Ended up going with this...
  nodes = Enumerable.From(Places)
        .Select(function(value, index){
            var p_ps = Enumerable.From(Places_Places)
                .Where(function(x){
                    return x.childId == value.id;
                })
                .ToArray();
            if(p_ps.length == 0){
                return value;
            }
        })
        .ToArray();
    for(var i = 0; i < nodes.length; i++){
        if(nodes[i] instanceof Place){
             rootNodes.push(nodes[i]);
        }
    }
Ugly but it works