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.

Asked 3 years ago
Viewed 1430 times

0

How to use Inner Join in SQL Server with example and write a SQL query to find the salesperson and customer who belongs to the same city. Return Salesman, cust_name, and city.


1 Answer


0

SQL JOIN Command :
 The SQL JOIN query 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.
1- Inner join.
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.
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.

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.
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.

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.



 
answered 3 years ago by Ashutosh Kumar Verma

Your Answer