---
title: "SQL Inner JOIN By Two Columns Tricky Example"
description: "Simple ideas and quickly what you need to find to write a query for joining of two tables explained."
url: https://srinimf.com/2020/05/24/how-to-write-query-to-join-tables/
date: 2020-05-24
modified: 2021-07-17
author: "Srini"
image: https://i0.wp.com/srinimf.com/wp-content/uploads/2020/05/pexels-photo-6180674.jpeg?fit=1880%2C1253&ssl=1
categories: ["SQL"]
tags: ["Ideas to Write SQL Join Query", "SQL Joins"]
type: post
lang: en
---

# SQL Inner JOIN By Two Columns Tricky Example

Here is SQL Inner Join example of two tables. The first thing you need is common key for both tables. That means common fields of both the tables on which you are going to join. If you know table structure of both the tables, it is very easy to find Key field, and you can write join SQL query easily.

**SQL Inner JOIN By Two Columns Tricky Example**

## Tricky SQL Inner Join Example Query

Here you can join Customer_Table and Order_Table using common keys. Here is you can find [inner vs outer join difference](https://srinimf.com/2018/01/05/equi-join-vs-inner-join-top-differences-to-read-today/)s and which is better.

```
SELECT
 Customer_Number
 ,a.Customer_Name
 ,b.Order_Number
 ,b.Order_Total
FROM   Customer_Table a
INNER JOIN
        Order_Table b
Using (Customer_Number, phone_number) ;
```

**Bottomline**

- I used here two tables. One is customer_table and the other one is order_table. Now know the key fields so you can complete your query easily.
- Key is: **using(customer_number, PHONE_NUMBER**)
- The columns in the **using** are common to both the tables.

Related Posts

- [How to Join 3 Tables—Without Join Keyword](https://srinimf.com/2021/04/24/how-to-sql-query-to-join-three-tables/)DateApril 24, 2021
- [How to Fix SQL Ambiguous Column Error](https://srinimf.com/2018/02/11/sql-ambiguous-column/)DateFebruary 11, 2018
- [Join Vs Sub-query Top Differences to Read Today](https://srinimf.com/2010/04/20/db2-join-vs-sub-query/)DateApril 20, 2010

## SQL JOIN With Using

[![SQL JOIN Example: Using Vs. ON This is the Difference](https://i0.wp.com/srinimf.com/wp-content/uploads/2020/01/pexels-photo-1438081.jpeg?resize=1200%2C900&ssl=1)](https://srinimf.com/2020/01/29/sqlquery-joins-how-to-write-with-using/)

### [SQL JOIN Example: Using Vs. ON This is the Difference](https://srinimf.com/2020/01/29/sqlquery-joins-how-to-write-with-using/)

Two top methods to JOIN tables with Using and ON. Here are useful SQL queries to understand quickly.

[![Srini&apos;s avatar](https://secure.gravatar.com/avatar/f10b4bafeeb96dce9806c5a3c6cde6ea1e2c014ef273120a4bf2c6d5f975f01c?s=48&r=g)](https://srinimf.com/author/moonrobot/)
by [Srini](https://srinimf.com/author/moonrobot/)
January 29, 2020October 10, 2026

### Share this:

-
- [Tweet](https://twitter.com/share)
- [![](https://i0.wp.com/assets.pinterest.com/images/pidgets/pinit_fg_en_rect_gray_20.png)](https://www.pinterest.com/pin/create/link/?url=https%3A%2F%2Fsrinimf.com%2F2020%2F05%2F24%2Fhow-to-write-query-to-join-tables%2F&media=https%3A%2F%2Fi0.wp.com%2Fsrinimf.com%2Fwp-content%2Fuploads%2F2020%2F05%2Fpexels-photo-6180674.jpeg%3Ffit%3D1200%252C800%26ssl%3D1&description=SQL%20Inner%20JOIN%20By%20Two%20Columns%20Tricky%20Example)
-
- [Share on Tumblr](https://www.tumblr.com/share)
- [Share on WhatsApp (Opens in new window) WhatsApp](https://srinimf.com/2020/05/24/how-to-write-query-to-join-tables/?share=jetpack-whatsapp)
- [More](#)
-

- [Print (Opens in new window) Print](https://srinimf.com/2020/05/24/how-to-write-query-to-join-tables/?share=print)
- [Share on Reddit (Opens in new window) Reddit](https://srinimf.com/2020/05/24/how-to-write-query-to-join-tables/?share=reddit)
- [Share on Telegram (Opens in new window) Telegram](https://srinimf.com/2020/05/24/how-to-write-query-to-join-tables/?share=telegram)
- [Email a link to a friend (Opens in new window) Email](mailto:?subject=%5BShared%20Post%5D%20SQL%20Inner%20JOIN%20By%20Two%20Columns%20Tricky%20Example&body=https%3A%2F%2Fsrinimf.com%2F2020%2F05%2F24%2Fhow-to-write-query-to-join-tables%2F&share=email)
-

### Like this:

Like Loading…
