---
title: "How to Use DFSORT JOINKEYS to Get Matching Records"
description: "Syntax for joinkeys to get matching records from multiple files. Read more."
url: https://srinimf.com/2016/02/26/2-key-points-you-never-ignore-in-joinkeys-of-dfsort/
date: 2016-02-26
modified: 2026-10-07
author: "Srini"
image: https://i0.wp.com/srinimf.com/wp-content/uploads/2016/02/pexels-photo-4473569.jpeg?fit=1880%2C1253&ssl=1
categories: ["DFSORT"]
tags: ["DFSORT JOINKEYS"]
type: post
lang: en
---

# How to Use DFSORT JOINKEYS to Get Matching Records

DFSORT Logic to get matching records from two or more input files, using the JOINKEYS parameter.

Related[JOIN KEY in DFSORT 2 Top Examples](https://srinimf.com/2011/10/24/jcl-how-to-compare-gdg-versions-with-sort/)

![Comedy](https://i0.wp.com/srinimf.com/wp-content/uploads/2016/02/commedy.gif?resize=600%2C482&ssl=1)

## Syntax for JOINKEYS

```
JOINKEYS F1=IN1,FIELDS=(22,3,A,55,9,D) 
JOINKEYS F2=IN2,FIELDS=(15,3,A,1,9,D)
```

### Explanation

- You should not use the same DD name on two statements (in F1 and F2)
- The order for both files should match (A- Ascending and D -Descending should be the same)

**Also read**

- [JOIN KEY in DFSORT 2 Top Examples](https://srinimf.com/2011/10/24/jcl-how-to-compare-gdg-versions-with-sort/)DateOctober 24, 2011
- [DFSORT JOINKEYS Sample JCL Explained Each Step](https://srinimf.com/2016/11/17/the-best-sort-join-key-example-to-create-3rd-data-set/)DateNovember 17, 2016
- [COBOL Interview Question – How To Deal With Two Files](https://srinimf.com/2014/03/21/cobol-interview-questions-on-files/)DateMarch 21, 2014

### 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%2F02%2F26%2F2-key-points-you-never-ignore-in-joinkeys-of-dfsort%2F&media=https%3A%2F%2Fi0.wp.com%2Fsrinimf.com%2Fwp-content%2Fuploads%2F2016%2F02%2Fpexels-photo-4473569.jpeg%3Ffit%3D1200%252C800%26ssl%3D1&description=How%20to%20Use%20DFSORT%20JOINKEYS%20to%20Get%20Matching%20Records)
-
- [Share on Tumblr](https://www.tumblr.com/share)
- [Share on WhatsApp (Opens in new window) WhatsApp](https://srinimf.com/2016/02/26/2-key-points-you-never-ignore-in-joinkeys-of-dfsort/?share=jetpack-whatsapp)
- [More](#)
-

- [Print (Opens in new window) Print](https://srinimf.com/2016/02/26/2-key-points-you-never-ignore-in-joinkeys-of-dfsort/?share=print)
- [Share on Reddit (Opens in new window) Reddit](https://srinimf.com/2016/02/26/2-key-points-you-never-ignore-in-joinkeys-of-dfsort/?share=reddit)
- [Share on Telegram (Opens in new window) Telegram](https://srinimf.com/2016/02/26/2-key-points-you-never-ignore-in-joinkeys-of-dfsort/?share=telegram)
- [Email a link to a friend (Opens in new window) Email](mailto:?subject=%5BShared%20Post%5D%20How%20to%20Use%20DFSORT%20JOINKEYS%20to%20Get%20Matching%20Records&body=https%3A%2F%2Fsrinimf.com%2F2016%2F02%2F26%2F2-key-points-you-never-ignore-in-joinkeys-of-dfsort%2F&share=email)
-

### Like this:

Like Loading…
