---
title: "Two SQL queries on Self-join and Inner-Join"
description: "Self join vs Inner join learn here using the best examples. Read more."
url: https://srinimf.com/2016/09/08/2-simple-sql-queries-on-self-join-and-inner-join/
date: 2016-09-08
modified: 2026-10-10
author: "Srini"
categories: ["SQL"]
tags: ["2 best examples on Self join and Inner join"]
type: post
lang: en
---

# Two SQL queries on Self-join and Inner-Join

I have given two examples. Those are self and inner join.

## SQL Query on Inner Join

```
SELECT PROJNO,EMPNO,LASTNAME,DEPTNAME
FROM  (TEST.EMP E  JOIN       
TEST.DEPT  DON        
D.DEPTNO = E.WORKDEPT)  JOIN              
TEST.PROJ. P
ON        EMPNO = RESPEMP;
```

Related[Join Vs Sub-query Top Differences to Read Today](https://srinimf.com/2010/04/20/db2-join-vs-sub-query/)

The above is the best example for finding match in 3 tables using Inner join.

## SQL Query on Self-Join

```
SELECT A.DEPTNO,A.DEPTNAME,
A.ADMRDEPT,A.DEPTNAMEFROM TEST.DEPT A             
TEST.DEPT B
WHERE A.ADMRDEPT =A.DEPTNO;
```

The above SQL query is the best example for self join.

Related[7 Exclusive Ideas to Enhance DB2 Performance](https://srinimf.com/2023/10/05/db2-sql-performance/)

### 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%2F2016%2F09%2F08%2F2-simple-sql-queries-on-self-join-and-inner-join%2F&media=https%3A%2F%2Fi0.wp.com%2Fsrinimf.com%2Fwp-content%2Fuploads%2F2026%2F02%2Fcropped-logo.png%3Ffit%3D96%252C96%26ssl%3D1&description=Two%20SQL%20queries%20on%20Self-join%20and%20Inner-Join)
-
- [Share on Tumblr](https://www.tumblr.com/share)
- [Share on WhatsApp (Opens in new window) WhatsApp](https://srinimf.com/2016/09/08/2-simple-sql-queries-on-self-join-and-inner-join/?share=jetpack-whatsapp)
- [More](#)
-

- [Print (Opens in new window) Print](https://srinimf.com/2016/09/08/2-simple-sql-queries-on-self-join-and-inner-join/?share=print)
- [Share on Reddit (Opens in new window) Reddit](https://srinimf.com/2016/09/08/2-simple-sql-queries-on-self-join-and-inner-join/?share=reddit)
- [Share on Telegram (Opens in new window) Telegram](https://srinimf.com/2016/09/08/2-simple-sql-queries-on-self-join-and-inner-join/?share=telegram)
- [Email a link to a friend (Opens in new window) Email](mailto:?subject=%5BShared%20Post%5D%20Two%20SQL%20queries%20on%20Self-join%20and%20Inner-Join&body=https%3A%2F%2Fsrinimf.com%2F2016%2F09%2F08%2F2-simple-sql-queries-on-self-join-and-inner-join%2F&share=email)
-

### Like this:

Like Loading…
