Hackforge Academy

Category: java

JOIN in SQL

Published on 24 Feb 2026

Explanation


INNER JOIN returns matching records from both tables.

Code:

SELECT u.name,o.id FROM 
users u INNER JOIN orders o ON u.id=o.user_id;

Explanation


LEFT JOIN returns all records from left
table and matched records from right table.

Code:

SELECT u.name,o.id FROM 
users u LEFT JOIN orders o ON u.id=o.user_id;

Explanation


RIGHT JOIN returns all records from right
table and matched records from left table.

Code:

SELECT u.name,o.id FROM users u 
RIGHT JOIN orders o ON u.id=o.user_id;

Explanation


JOIN using alias improves readability.

Code:

SELECT u.name FROM users u 
INNER JOIN orders o ON u.id=o.user_id;

Explanation


JOIN with WHERE condition filters combined results.

Code:

SELECT u.name,o.id FROM users u 
INNER JOIN orders o ON u.id=o.user_id WHERE u.id=1;

πŸš€ Learn Spring Boot with real-world projects

πŸ’‘ Build REST APIs step by step

🧠 Improve backend development skills

🎯 Get career-ready practical training

Join Our Free WhatsApp Community

Direct access to niche-specific mentors and peers on WhatsApp.

🐍

Python Community

Discuss Django, FastAPI, AI integration, and automation scripts with 15k+ developers.

Join Python Community
βš›οΈ

React Community

Master Next.js, Framer Motion, and State Management. Share your latest UI components.

Join React Community
β˜•

Java Community

Deep dives into Spring Boot, Microservices architecture, and high-performance backend ops.

Join Java Community