- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Example and usage of JOINS in DB2
Problem: How will you find the ORDER_ID, TRANSACTION_ID and TRANSACTION_STATUS from ORDERS and TRANSACTIONS DB2 table using joins?
Solution
We can find ORDER_ID, TRANSACTION_ID and TRANSACTION_STATUS from ORDERS and TRANSACTIONS table using the INNER JOIN query.
For example, if we have below 2 ORDERS table.
ORDER_ID | TRANSACTION_ID | ORDER_DATE |
Z22345 | ITX4489 | 23-10-2020 |
Z62998 | ITX4311 | 21-10-2020 |
Z56902 | ITX3120 | 26-10-2020 |
TRANSACTION_ID | TRANS_AMT | TRANSACTION_STATUS |
ITX4489 | 1128 | PAID |
ITX4311 | 2318 | PAID |
ITX3120 | 88956 | UNPAID |
ITX2167 | 5612 | FAILED |
We can use an inner join query as below.
Example
SELECT ORDER_ID, TRANSACTION_ID, TRANSACTION_STATUS FROM ORDERS INNER JOIN TRANSACTIONS ON ORDERS.TRANSACTION_ID = TRANSACTIONS.TRANSACTION_ID
The above query will return the result below.
ORDER_ID | TRANSACTION_ID | TRANSACTION_STATUS |
Z22345 | ITX4489 | PAID |
Z62998 | ITX4311 | PAID |
Z56902 | ITX3120 | UNPAID |
- Related Articles
- Usage and example of Multi-index and Index-only access path in DB2
- Purpose and usage of SAVEPOINT in COBOL-DB2 program
- Usage and syntax of INNER and OUTER JOIN in DB2
- Purpose and usage of ROW-ID and SEQUENCE in a DB2
- Error codes, cause and example of deadlock in DB2
- What is the definition and usage of alternate key in a DB2 table?
- What is the usage and purpose of DCLGEN and host variables used in COBOL-DB2 program
- What is the purpose and usage of “WHERE CURRENT OF” clause in a COBOL-DB2 program?
- What is the purpose and usage of “FOR UPDATE OF” clause in a COBOL-DB2 program
- What is the purpose and usage of SQLCODE within the SQLCA in a COBOL-DB2 program
- Purpose and usage of subqueries in DB with the help of an example
- Explain the concept of DYNAMIC SQL in DB2 with the help of an example
- What is CLUSTERED INDEX in DB2? Explain with the help of practical example.
- What are COLUMN functions in DB2? Explain with the help of an example
- What is NON CLUSTERED INDEX in DB2? Explain with the help of practical example

Advertisements