• Announcements

    • xper

      MSFN Sponsorship and AdBlockers!   07/10/2016

      Dear members, MSFN is made available via subscriptions, donations and advertising revenue. The use of ad-blocking software hurts the site. Please disable ad-blocking software or set an exception for MSFN. Alternatively, become a site sponsor and ads will be disabled automatically and by subscribing you get other sponsor benefits.
Cyrius

SQL Query

1 post in this topic

Hi guys, I was wondering if you could give me a hand with an SQL query, I am rusty.

I need to show a user's name rather than the integer for their name. For example, the code below is showing 318512 as the user for inside sales on a customer.

I got the key relationship set up right (I think) but I need the columns Inside Sales and Outside sales to show U.First_Name+U.Last_Name.

One other confusing me is the foreign key being tied to two fields.

I used the left outer join because there are some null values in the customer table for both Inside and Outside sales.

SELECT

C.Name AS 'Customer Name',

C.Customer_Status,

C.Customer_Type,

C.Phone,

C.Fax,

C.Out_Sales AS 'Outside Sales',

C.In_Sales AS 'Inside Sales'

FROM Customer AS C LEFT OUTER JOIN User AS U

ON C.Out_Sales = U.User_No

AND C.In_Sales = U.User_No

WHERE Customer_Type = 'Retail'

0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.