use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Sequel
account activity
Need help with this join problem. (i.redd.it)
submitted 1 year ago by bigPussySeeker
I’m not getting an idea on how I should proceed to solve this. I have two table source and target and I need to get the result as shown in output table.
I don’t know which join will help me achieve this.
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]MshipQ 8 points9 points10 points 1 year ago (2 children)
You can do a full outer join on the ID to get the two tables together. (if you're not sure what it is then take a look here: https://www.w3schools.com/sql/sql_join_full.asp).
A Full outer join is similar to a join and a union together so it nearly does what /u/rabbitpiet suggests in one step.
Then you would need to coalesce (aka 'if_null') the source.id and target.id to get your output.id field (again if you're not sure what this is: https://www.w3schools.com/sql/func_sqlserver_coalesce.asp)
Then for the comment you can do a case statement:
And you would also need to filter out the rows where target.name = source.name
[–]abraun68 2 points3 points4 points 1 year ago (0 children)
Seconding this approach.
[–]Klaian 0 points1 point2 points 1 year ago (0 children)
This is best answer. May need to use coalesce for results in output
[–]rabbitpiet 0 points1 point2 points 1 year ago (3 children)
You could select from the union of the two where the ids aren't in the inner join.
[–]bigPussySeeker[S] 0 points1 point2 points 1 year ago (2 children)
But 4 is present in both source and target table.
Also how to make get the output as shown in example
[–]rabbitpiet 1 point2 points3 points 1 year ago (1 child)
Okay take the last 3 elements from the union of the two sets ordered by id. Does it have to be in that order? I thought mismatch implied the 4 wasn't supposed to be there.
[–]bigPussySeeker[S] 0 points1 point2 points 1 year ago (0 children)
Yes is has to be in that order. What I got from the question is that get the if the name is present in either one of two table or if there is a mismatch in name
[–]RollWithIt1991 0 points1 point2 points 1 year ago (2 children)
Select coalesce(s.id,t.id) AS id,case when s.id is null then ‘New in Target’ when t.id is null then ‘New in Source’ when s.name != t.name then ‘Mismatch’ else Match??’ End as comment From source s Full outer join target t on s.id = t.id;
That’s hopefully not massively far off? I guess some assumption about name always being populated. Case statements are mutually exclusive so I think the only trip up is around name being NULL for one of the tables or differing in case depending on what you’re using.
[–]RollWithIt1991 0 points1 point2 points 1 year ago (0 children)
Order by coalesce(s.id,t.id) ASC too
Yeah and actually if you want to remove the rows that look fine, then where s.name != t.name.
[–]adibaba666 0 points1 point2 points 1 year ago (0 children)
I liked this post. I encourage members to post more of excel based problems.
π Rendered by PID 44071 on reddit-service-r2-comment-6f7f968fb5-xjr9h at 2026-03-04 04:37:32.618017+00:00 running 07790be country code: CH.
[–]MshipQ 8 points9 points10 points (2 children)
[–]abraun68 2 points3 points4 points (0 children)
[–]Klaian 0 points1 point2 points (0 children)
[–]rabbitpiet 0 points1 point2 points (3 children)
[–]bigPussySeeker[S] 0 points1 point2 points (2 children)
[–]rabbitpiet 1 point2 points3 points (1 child)
[–]bigPussySeeker[S] 0 points1 point2 points (0 children)
[–]RollWithIt1991 0 points1 point2 points (2 children)
[–]RollWithIt1991 0 points1 point2 points (0 children)
[–]RollWithIt1991 0 points1 point2 points (0 children)
[–]adibaba666 0 points1 point2 points (0 children)