troubleshooting Question

How to retrieve sql data?

Avatar of swansonplace
swansonplace asked on
SQL
3 Comments1 Solution247 ViewsLast Modified:
I am trying to perform a select on the below code, but I am not performing the select correctly.  Could you let me know what the query should look like?

Company --> Company.Code
Company_Rules --> Company_Rules.Company

Sample Input Data

Company                
Code
1
2
3

Company Rules
Company                      Rule Code
1                                        100              
1                                        200
3                                        101

Desired Output
Code                      company
1                                1
2                              Null
3                                3

In essence I want all of the company data that that with the matching company_rules data.  But the resulting output does not return multiple rows of company_rules.  The data that does not find a matching company_rules field is also return.

ASKER CERTIFIED SOLUTION
Aneesh
Database Consultant
Join our community to see this answer!
Unlock 1 Answer and 3 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 3 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros