Filtrar texto

SQL intermedio con IA

Jasmin Ludolf

Senior Data Science Content Developer

Coincidencia de patrones

Un libro

SQL intermedio con IA

Coincidencia de patrones

Colección de libros

SQL intermedio con IA

Comodines

$$

  • *: seleccionar todo

$$

Dos comodines para coincidencia de patrones:

  • %
  • _

Comodines

SQL intermedio con IA

Coincidencia de texto con %

Instrucción: Mostrar títulos de películas que contengan 'love'

SELECT title
FROM films
WHERE title LIKE '%love%';
|title                   |
|------------------------|
|Dr. Strangelove or: H...|
|Beloved                 |
|Cloverfield             |
|The Oogieloves in the...|
...

$$

%:

  • Coincide con cualquier carácter
  • Sensible a mayúsculas
  • %love%:
    • Cualquier cosa antes o después de "love"
    • Exactamente "love" en minúsculas
SQL intermedio con IA

Sensibilidad a mayúsculas

Instrucción: Mostrar títulos de películas que contengan 'love' en cualquier caso

SELECT title 
FROM films
WHERE title ILIKE '%love%';
|title                |
|---------------------|
|Intolerance: Love'...|
|Love Me Tender       |
|From Russia with Love|
...
SQL intermedio con IA

Sensibilidad a mayúsculas

SELECT title 
FROM films
WHERE LOWER(title) LIKE '%love%';

$$

  • Título original: "Love Actually"
  • LOWER(title): "love actually"
    • Coincide con "love"
SELECT title 
FROM films
WHERE UPPER(title) LIKE '%LOVE%';

$$

  • Título original: "Love Actually"
  • UPPER(title): "LOVE ACTUALLY"
    • Coincide con "LOVE"
SQL intermedio con IA

Coincidencia de texto con %

Instrucción: Mostrar títulos de películas que terminen con 'and', cualquier caso

SELECT title
FROM films
WHERE LOWER(title) LIKE '%and';
|title                   |
|------------------------|
|Alexander's Ragtime Band|
|Wonderland              |
|Finding Neverland       |
...

Instrucción: Mostrar títulos de películas que comiencen con 'and', cualquier caso

SELECT title
FROM films
WHERE LOWER(title) LIKE 'and%';
|title             |
|------------------|
|And Then Came Love|
|Anderson's Cross  |
|And So It Goes    |
SQL intermedio con IA

Coincidencia de texto con _

Instrucción: Mostrar títulos de películas de cinco letras que comiencen con E

SELECT title
FROM films
WHERE title LIKE 'E____';
|title|
|-----|
|Evita|
|Earth|
  • "Elf" o "Enchanted" no coinciden
SQL intermedio con IA

Excluir valores de texto

Instrucción: Mostrar títulos de películas que no comiencen con 'The'

SELECT title
FROM films
WHERE title NOT LIKE 'The%';
|title               |
|--------------------|
|Intolerance: Love...|
|Over the Hill to ...|
|Metropolis          |
...
SQL intermedio con IA

Coincidencia de patrones

  • Encontrar similitudes en texto

Correos de marketing

SQL intermedio con IA

Coincidencia de patrones

  • Encontrar similitudes en texto

Finanzas y productos

SQL intermedio con IA

Coincidencia de patrones

  • Encontrar similitudes en texto

$$

$$

$$

  • Sensible a mayúsculas
  • Comodines
    • *: selecciona todos los campos
    • _: coincidencia de caracteres
    • %: posición

IA con lupa

  • LIKE: coincidencia de patrones
  • NOT LIKE: excluye patrones
  • ILIKE: insensible a mayúsculas
  • UPPER() / LOWER(): estandarizar mayúsculas
SQL intermedio con IA

¡Vamos a practicar!

SQL intermedio con IA

Preparing Video For Download...