Questions tagged [outer-join]

An outer join defines a relationship between two tables where all records from one or both tables are returned regardless of the existence of a matching key-field in the other table. A full outer join combines the results of both tables. A left or right join returns all the records from the first or second specified table, respectively. NULLS are filled in for matches on either side. A self-join compares a table to a copy of itself.

A full combines the results of both tables. A left or right returns all the records from the first or second specified table, respectively. NULLS are filled in for matches on either side. A compares a table to a copy of itself.

References

1671 questions
4
votes
3 answers

Workaround for outer join with an IN operator in Oracle

I am using Oracle SQL, so outer joins have the nice (+) syntax. I should warn you that I am not allowed to redesign the database; I work for a large organization. Here are some example tables: People PersonID Name 1 Elmo 2 …
Chris Cunningham
  • 1,875
  • 1
  • 15
  • 27
4
votes
2 answers

OUTER JOIN with SQL across multiple tables in SQL Server 2008

I have a SQL Server 2008 database. This database has three tables: Person - Id - FullName - MembershipStatusId (nullable) - HairStyleId (nullable) MembershipStatus - Id - Name HairStyle - Id - ColorName - Description I need to…
JavaScript Developer
  • 3,968
  • 11
  • 41
  • 46
4
votes
3 answers

Multiple use of LEFT JOIN brings only 1 row

It is an intelligent tag base image search system. User adds images with its proper tags in such a table: image (id, title, ...) tag (id, title) /* It doesn't matter who has created the tag*/ imagetag (image_id, tag_id) /* One image may have…
Mohammad Naji
  • 5,372
  • 10
  • 54
  • 79
3
votes
2 answers

Matlab outer product like function? How?

I have the following computation I'd like to vectorize in matlab. I have a N x 3 array, call it a. I have a 4 x 1 cell array of function handles, call them b. I would like to create an Nx4 matrix c, such that c(i,j) = b{j}(a(i,:). b is actually an…
John
  • 5,735
  • 3
  • 46
  • 62
3
votes
1 answer

You're trying to access a column, but multiple columns have that name

I am trying to join 2 dataframes such that both have the following named columns. What's the best way to do a LEFT OUTER join? df = df.join(df_forecast, ["D_ACCOUNTS_ID", "D_APPS_ID", "D_CONTENT_PAGE_ID"], 'left') Currently, I get an error…
x89
  • 2,798
  • 5
  • 46
  • 110
3
votes
4 answers

Why doesn't my query return any results?

Why does this sql query only show results if they only have a row in users_warnings? SELECT u.id, uw.warning FROM users u INNER JOIN users_warnings uw ON ( u.id = uw.uID ) LIMIT 21 I wish to show all users, but also grab the column…
Karem
  • 17,615
  • 72
  • 178
  • 278
3
votes
1 answer

PostgreSQL INNER JOIN AND OUTER JOIN WITH SOME NULL VALUES LOGIC

I have these 2 tables: games_during_trial +---------------------------------+ |account_id |game | +---------------------------------+ | 1 | Minecraft | | 1 | Overwatch | | 2 | NULL …
3
votes
3 answers

MySQL, three tables: Select all rows in right table including rows that are not mapped in middle table

My schema are as follows: Sites S | S.Id | S.Url | | 1 | a.com | | 2 | b.edu | | 3 | c.org | SiteFeatures SF | SF.SiteId | SF.FeatureID | | 1 | 1 | | 1 | 2 | | 1 | 3 | | 2 |…
JDS
  • 1,869
  • 1
  • 15
  • 17
3
votes
2 answers

mysql outer join - determine if the joined row exists

I have two tables with the same primary key, but one is much much larger than the other. I want to know which ids have a row in the smaller table. (In the example, a is large and b is small). Right now, I'm using an OUTER JOIN with a CASE to…
jmilloy
  • 7,875
  • 11
  • 53
  • 86
3
votes
4 answers

How to retrieve all the data from the Left Table while using Group by on 2nd table with Having Condition

Consider three tables, Team Members (Each member belongs to some team) Tasks (each task is performed by some member) Tasks Table t_id member_id 1 1 2 1 3 2 4 1 Members Table id name team_id 1 Ali …
Sakib Khan
  • 305
  • 2
  • 13
3
votes
1 answer

Numpy: Outer sum along a specific axis

I'm looking for an efficient way to do an outer sum over a 2d matrix columns. Let say A is a (2, 3) matrix, my wanted result is shaped (3,2,2) and defined as : A = np.array([[a11, a12, a13], [a21, a22, a23]]) myWantedResult =…
3
votes
1 answer

Remove duplicate left outer join

I need help to merge 2 duplicate rows from the below result from my sql query. Result Query SELECT DISTINCT a.[LocationID], a.[BuildingCode], a.[LocationCode], a.[LocationName], c.UserName, d.RoleName FROM …
3
votes
2 answers

How do I full join in Mysql?

I have two tables: T1 1,a 2,b T2 2,ggg 3,hhh I want the join between them to give me all fields: 1,a,null,null 2,b,2,ggg null,null,3,hhh
Itay Moav -Malimovka
  • 52,579
  • 61
  • 190
  • 278
3
votes
1 answer

How can I run an outer join on two large postgreSQL tables in batches?

I have two tables with millions of rows. They share a common email address. They don't share any other fields. I have a join operation that works fine. select r.*,l.* from righttable r full outer join lefttable l on r.email=l.email However, the…
GNG
  • 1,341
  • 2
  • 23
  • 50
3
votes
2 answers

R Element-to-Element operations on several columns in groups

We have the mtcars dataset and want to compute a function between different cars in groups taking several columns as input. More specifically: Group by transmission am and gears gear Compare all cars within the same group with each other (car1 to…
JaBe
  • 664
  • 1
  • 8
  • 27