Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Lære SQL Like | Filtering Statements
SQL Tutorial for Beginners

book
SQL Like

The LIKE operator is used with WHERE to search for some pattern in a string.

The pattern is usually some kind of Regular Expression that is built with some rules, but we won't dive deep into it. In the meantime, the following rules are enough for you:

  • % means 0 or more symbols: a% matches a, aa, aaaaa, etc. b%d matches bd, bad, bored, etc.

  • _ matches single symbol. t_ee matches tree, twee etc, and _o%_ match wow, coooow, soap etc., but not so for example.

In this example all singers with the naming of two separate words, both consist of at least one symbol.

SELECT singer FROM songs
WHERE singer LIKE '_% _%'
12
SELECT singer FROM songs WHERE singer LIKE '_% _%'
copy
Opgave

Swipe to start coding

Select all singers with naming starting with A.

Løsning

SELECT DISTINCT singer FROM songs
WHERE singer LIKE 'A%'

Var alt klart?

Hvordan kan vi forbedre det?

Tak for dine kommentarer!

Sektion 3. Kapitel 2

Query ResultQuery Result
No query executed yet...

Spørg AI

expand
ChatGPT

Spørg om hvad som helst eller prøv et af de foreslåede spørgsmål for at starte vores chat

We use cookies to make your experience better!
some-alt