MongoDB to Use Sharding with $lookup Aggregation Operator

As the docs you quote indicate, you can’t use $lookup on a sharded collection. So the best practice workaround is to perform the lookup yourself in a separate query. Perform your aggregate query. Pull the “localField” values from your query results into an array, possibly using Array#map. Perform a find query against the “from” collection, … Read more

HQL left join of un-related entities

Currently, the theta-style on joining the unrelated classes in the where clause using HQL only supports inner join. The request for supporting the outer join for such situation is currently the 3-rd most voted enhancement but I don’t think this feature will be implemented in the near feature as it requires the re-implementation of the … Read more

Select first record in a One-to-Many relation using left join

After playing around a bit, this turns out to be trickier than I’d expected! Assuming that table_b has some single column that is unique (say, a single-field primary key), it looks like you can do this: SELECT table_a.code, table_a.emp_no, table_b.city, table_b.county FROM table_a LEFT JOIN table_b ON table_b.code = table_a.code AND table_b.field_that_is_unique = ( SELECT … Read more

SQL Oracle LEFT JOIN and SUBQUERY error: ORA-00905: missing keyword

In Oracle we don’t include the AS when declaring a table alias. Instead of ) AS TABLE_RESOLVERS write ) TABLE_RESOLVERS This is one example when Oracle syntax is more restrictive than some other flavours of SQL. It is also inconsistent with the declaration of column aliases, which is unfortunate but almost certainly it’s too complex … Read more