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

Queries with constraints (Pt. 1)

SQL Lesson 2

SELECT column 
FROM mytable 
WHERE condition 
AND/OR condition ...;
Operador
Condición

=, !=, < <=, >, >=

Operadores numéricos estándar

BETWEEN … AND …

Número que se encuentre dentro del rango (inclusivo)

NOT BETWEEN … AND …

Número que no se encuentre dentro del rango (inclusivo)

IN (...)

Número existente en una lista

NOT IN (...)

Número no existente en una lista


  1. Encuentra la película con el id igual a 6.

SELECT * 
FROM movies 
WHERE id=6;
  1. Encuentra las películas estrenadas entre los años 2000 y 2010.

SELECT * 
FROM movies 
WHERE year BETWEEN 2000 AND 2010;
  1. Encuentra las películas no estrenadas entre los años 2000 y 2010.

SELECT * 
FROM movies 
WHERE year NOT BETWEEN 2000 AND 2010;
  1. Encuentra las primeras cinco películas de Pixar y su año de lanzamiento.

SELECT title,year 
FROM movies 
WHERE id BETWEEN 1 AND 5;
PreviousSELECT queries 101NextQueries with constraints (Pt. 2)

Last updated 1 year ago