outer-join

Left Outer Join not returning all records from primary table

筅森魡賤 提交于 2019-12-05 03:40:59
When I do a left outer join, I expect to get all the records that the query would return prior to adding the joined table, but it is only returning records that match the joined table (i.e: no record for '092387' exists in table 'documentation', so I just want null returned for 'filename' field for that record.) What am I doing wrong? mysql> select documentation_reference.ref_docnumber , documentation.filename from documentation_reference left outer join documentation on ref_docnumber=documentation.docnumber where documentation_reference.docnumber='TP-036' and documentation.status!=3; +-------

How does one do a full join using data.table?

一曲冷凌霜 提交于 2019-12-04 23:58:52
In the data.table FAQ , the nomatch = NA parameter is said to be akin to an outer join. However, I haven't been able to get data.table to do a full outer join – only right outer joins. For example: a <- data.table("dog" = c(8:12), "cat" = c(15:19)) dog cat 1: 8 15 2: 9 16 3: 10 17 4: 11 18 5: 12 19 b <- data.table("dog" = 1:10, "bullfrog" = 11:20) dog bullfrog 1: 1 11 2: 2 12 3: 3 13 4: 4 14 5: 5 15 6: 6 16 7: 7 17 8: 8 18 9: 9 19 10: 10 20 setkey(a, dog) setkey(b, dog) a[b, nomatch = NA] dog cat bullfrog 1: 1 NA 11 2: 2 NA 12 3: 3 NA 13 4: 4 NA 14 5: 5 NA 15 6: 6 NA 16 7: 7 NA 17 8: 8 15 18 9

Full outer join two sequences of maps in Clojure

*爱你&永不变心* 提交于 2019-12-04 19:17:24
Given: (def seq1 ({:id 1 :val 10} {:id 2 :val 20})) (def seq2 ({:id 1 :val 12} {:id 3 :val 30})) Within each sequence, the :id value is guaranteed to be unique in that sequence, though not necessarily ordered. How can these two sequences of maps be joined by the :id key, so that the result is as shown? {1 [{:id 1 :val 10} {:id 1 :val 12}], 2 [{:id 2 :val 20} nil ], 3 [nil {:id 3 :val 30}]} The ultimate result is a map of pairs. This is similar to a full outer join, where not only the intersection, but also the difference of the two sets is included in the output. Here's the answer I came up

Full outer join in django

扶醉桌前 提交于 2019-12-04 11:04:15
问题 How can I create a query for a full outer join across a M2M relationchip using the django QuerySet API? It that is not supported, some hint about creating my own manager to do this would be welcome. Edited to add: @S.Lott: Thanks for the enlightenment. The need for the OUTER JOIN comes from the application. It has to generate a report showing the data entered, even if it still incomplete. I was not aware of the fact that the result would be a new class/model. Your hints will help me quite a

Efficient alternative to Outer on sparse arrays in Mathematica?

空扰寡人 提交于 2019-12-04 10:53:01
问题 Suppose I have two very large lists {a1, a2, …} and {b1, b2, …} where all ai and bj are large sparse arrays. For the sake of memory efficiency I store each list as one comprehensive sparse array. Now I would like to compute some function f on all possible pairs of ai and bj where each result f[ai, bj] is a sparse array again. All these sparse arrays have the same dimensions, by the way. While Flatten[Outer[f, {a1, a2, ...}, {b1, b2, ...}, 1], 1] returns the desired result (in principle) it

Outer merging two data frames in place in pandas

会有一股神秘感。 提交于 2019-12-04 00:58:05
问题 How can I outer merge two data frames in place in pandas? For example, assume we have these two data frames: import pandas as pd s1 = pd.DataFrame({ 'time':[1234567000,1234567005,1234567009], 'X1':[96.32,96.01,96.05] },columns=['time','X1']) # to keep columns order s2 = pd.DataFrame({ 'time':[1234567001,1234567005], 'X2':[23.88,23.96] },columns=['time','X2']) # to keep columns order They could be merged with pandas.DataFrame.merge ( s3 = pd.merge(s1,s2,how='outer') ) or with pandas.merge ( s3

SQL Alias of joined tables

断了今生、忘了曾经 提交于 2019-12-03 15:09:35
I have a query like this: select a1.name, b1.info from (select name, id, status from table1 a) as a1 right outer join (select id, info from table2 b) as b1 on (a1.id = b1.id) I only want to include everything where a1.status=1 and since I'm using an outer join, I can't just add a where constraint to table1, because all info from table2 that I want to be excluded will still be there, just without the name. I was thinking something like this: select z1.name, z1.info from ((select name, id, status from table1 a) as a1 right outer join (select id, info from table2 b) as b1 on (a1.id = b1.id)) as

C# Outer Apply in LINQ

大兔子大兔子 提交于 2019-12-03 13:05:57
问题 How can I achieve Outer Apply in LINQ? I'm having a bit of a problem. Here's the SQL Query I'm using. SELECT u.masterID ,u.user ,h.created FROM dbo.Users u OUTER APPLY (SELECT TOP 1 * FROM UserHistory h where h.masterID = u.masterID ORDER BY created DESC) h 回答1: from u in Users join UserHistory on u.masterID equals h.masterID into h select new {u.masterID, u.user, h.created.OrderByDescending().First()} 回答2: from u in Users join UserHistory on u.masterID equals h.masterID into h select new { u

Efficient alternative to Outer on sparse arrays in Mathematica?

两盒软妹~` 提交于 2019-12-03 06:48:01
Suppose I have two very large lists {a1, a2, …} and {b1, b2, …} where all ai and bj are large sparse arrays. For the sake of memory efficiency I store each list as one comprehensive sparse array. Now I would like to compute some function f on all possible pairs of ai and bj where each result f[ai, bj] is a sparse array again. All these sparse arrays have the same dimensions, by the way. While Flatten[Outer[f, {a1, a2, ...}, {b1, b2, ...}, 1], 1] returns the desired result (in principle) it appears to consume excessive amounts of memory. Not the least because the return value is a list of

Doing a left join with old style joins

走远了吗. 提交于 2019-12-02 17:51:21
问题 So I'm currently transcribing OracleSQL into a new PostgreSQL database. While I'm translating Oracle's (+) joins to LEFT OUTER JOIN s, this works very well. Except when combined with old style joins. Take this OracleSQL for example: SELECT * FROM table1, table2 alias1, table2 alias2, table2 alias3, table3, table4, table5, table6 table6alias WHERE table1.id_table3 = alias1.id_table3 AND table1.id_table4 = alias2.id_table4 AND table1.id_table3 = table3.id_table3 AND table1.id_table4 = table4.id