---
title: "How to use Inner Join in SQL Server with example and write a SQL query to find the salesperson and customer who belongs to same city. Return Salesman, cust_name and city."  
description: "How to use Inner Join in SQL Server with example and write a SQL query to find the salesperson and customer who belongs to same city. Return Salesman, cust_name and city."  
author: "Ethan Karla"  
published: 2021-09-14  
canonical: https://answers.mindstick.com/qa/93953/how-to-use-inner-join-in-sql-server-with-example-and-write-a-sql-query-to-find-the-salesperson-and-customer-who-belongs-to-same-city-return-salesman-cust_name-and-city  
category: "database"  
tags: ["database", "database management system"]  
reading_time: 2 minutes  

---

# How to use Inner Join in SQL Server with example and write a SQL query to find the salesperson and customer who belongs to same city. Return Salesman, cust_name and city.

How to use Inner [Join in SQL](https://www.mindstick.com/forum/33686/what-is-a-self-join-in-sql-server) [Server](https://www.mindstick.com/articles/43769/what-is-serverless-architecture-is-it-worth-switching-over) with example and write a [SQL query](https://www.mindstick.com/forum/529/rename-table-name-and-column-name-using-sql-query) to find the salesperson and [customer](https://www.mindstick.com/articles/324748/customer-journey) who belongs to the same city. Return Salesman, cust_name, and city.

## Answers

### Answer by Ashutosh Kumar Verma

**SQL JOIN Command :** The SQL JOIN [query](https://www.mindstick.com/blog/202/sub-query-in-sqlserver) is used to combine two or more tables base on common column name to retrieve record from all that tables. **Types of SQL JOIN Command :** There are 4 types of JOIN Command are used in [SQL Server](https://www.mindstick.com/articles/12343/sql-server-2017-ctp-2-0-now-available). 1- [Inner join](https://www.mindstick.com/forum/33572/sql-inner-join-keyword). 2- Left join. 3- Right join. 4- Full outer join. **Inner join :** In SQL Inner join command selects all common record from two or more table which have same column name. ![How to use Inner Join in SQL Server with example and write a SQL query to find the salesperson and customer who belongs to same city. Return Salesman, cust_name and city.](https://answers.mindstick.com/questionanswer/af7c27cc-d527-4992-9a4b-63be42f9cd29/images/ad5951b0-446b-417f-8518-95fd25bbe6de.png)\
**Example :** Following the SQL statement select the common record from both tables based on common column name i.e. ‘salesman_id’ is in both tables. **select * from Customer inner join Salesman on** **Customer.salesman_id=Salesman.salesman_id;** ![How to use Inner Join in SQL Server with example and write a SQL query to find the salesperson and customer who belongs to same city. Return Salesman, cust_name and city.](https://answers.mindstick.com/questionanswer/af7c27cc-d527-4992-9a4b-63be42f9cd29/images/72916222-7220-4b5f-a964-b82d2d89dc79.png) **\** **\** **Write the SQL inner join statement to find the Salesman and Customer who belongs to same city. Returns the salesperson, cust_name and city.** **Salesman Table :** ![How to use Inner Join in SQL Server with example and write a SQL query to find the salesperson and customer who belongs to same city. Return Salesman, cust_name and city.](https://answers.mindstick.com/questionanswer/af7c27cc-d527-4992-9a4b-63be42f9cd29/images/d42e2063-b616-4016-bd1f-da013301b46a.png) **\** **Customer Table ;** ![How to use Inner Join in SQL Server with example and write a SQL query to find the salesperson and customer who belongs to same city. Return Salesman, cust_name and city.](https://answers.mindstick.com/questionanswer/af7c27cc-d527-4992-9a4b-63be42f9cd29/images/a3a2df5a-22ae-4d1f-8bcf-af031397f265.png) **\** **\** **SQL Statement :** **select Salesman.name,Customer.cust_name,Customer.city from Salesman inner join Customer on \** **Salesman.salesman_id=Customer.salesman_id;** **\** ![How to use Inner Join in SQL Server with example and write a SQL query to find the salesperson and customer who belongs to same city. Return Salesman, cust_name and city.](https://answers.mindstick.com/questionanswer/af7c27cc-d527-4992-9a4b-63be42f9cd29/images/7e9f28d4-93b9-4b1d-865b-5e1a9eb21eeb.png) \
**\** **\**


---

Original Source: https://answers.mindstick.com/qa/93953/how-to-use-inner-join-in-sql-server-with-example-and-write-a-sql-query-to-find-the-salesperson-and-customer-who-belongs-to-same-city-return-salesman-cust_name-and-city

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
