stamin4
  • whoami
  • HTB Academy
    • Introduction to Academy
    • Learning Process
    • Vulnerability Assessment
    • Web Requests
    • Introduction to Networking
    • Linux Fundamentals
    • Brief Intro to Hardware Attacks
    • Setting Up
    • Using the Metasploit Framework
    • Security Incident Reporting
    • Introduction to Web Applications
    • JavaScript Deobfuscation
    • Attacking Web Applications with Ffuf
    • Windows Fundamentals
    • File Inclusion
  • HTB Machines
    • Windows
      • 🟢Easy
      • 🟠Medium
      • 🔴Difficult
      • 🟣Insane
    • Linux
      • 🟢Easy
        • Cap
      • 🟠Medium
      • 🔴Difficult
      • 🟣Insane
  • OverTheWire
    • Bandit
      • Nivel 0
      • Nivel 1
      • Nivel 2
      • Nivel 3
      • Nivel 4
      • Nivel 5
      • Nivel 6
      • Nivel 7
      • Nivel 8
      • Nivel 9
      • Nivel 10
  • Base de datos
    • SQL
      • SELECT queries 101
      • Queries with constraints (Pt. 1)
      • Queries with constraints (Pt. 2)
      • Filtering and sorting Query results
      • Simple SELECT Queries
      • Multi-table queries with JOINs
      • OUTER JOINs
      • A short note on NULLs
      • Queries with expressions
      • Queries with aggregates (Pt. 1)
      • Queries with aggregates (Pt. 2)
      • Order of execution of a Query
      • Inserting rows
      • Updating rows
      • Deleting rows
      • Creating tables
      • Altering tables
      • Dropping tables
  • PortSwigger
    • Path Traversal
  • Dockerlabs
    • Trust
    • Firsthacking
    • Upload
Powered by GitBook
On this page
  1. Base de datos
  2. SQL

OUTER JOINs

SQL Lesson 7

SELECT column(s) 
FROM mytable 
INNER/LEFT/RIGHT/FULL JOIN another_table 
	ON mytable.id = another_table.matching_id
  • RIGHT JOIN trae todos los de la derecha (tengan una relación o no).

  • LEFT JOIN trae todos los de la izquierda (tengan una relación o no).

  • FULL JOIN trae todos los datos.


  1. Encuentra la lista de todos los edificios que tienen empleados.

SELECT DISTINCT building_name 
FROM buildings 
INNER JOIN employees
	ON building_name=building;
SELECT DISTINCT building 
FROM employees;
  1. Encuentra la lista de todos los edificios y su capacidad.

SELECT * 
FROM buildings;
  1. Lista todos los edificios y los distintos roles de empleados en cada edificio, incluyendo los que están vacíos.

SELECT DISTINCT building_name,role 
FROM buildings 
LEFT JOIN employees 
	ON building_name=building;
PreviousMulti-table queries with JOINsNextA short note on NULLs

Last updated 1 year ago