Code Lab is in development. New lessons and improvements are on the way. Progress can be deleted.
Loading…
Code Lab is in development. New lessons and improvements are on the way. Progress can be deleted.
Loading…
Code Lab is in development. New lessons and improvements are on the way. Progress can be deleted.
SQL / POSTGRESQL / Learn / LESSON 07
LIKE compares text against a pattern. % matches any number of characters; _ matches one. PostgreSQL LIKE is case-sensitive. ILIKE is a PostgreSQL-specific case-insensitive variant; this lesson uses LIKE.
Small example:
SELECT name FROM customers WHERE name LIKE 'M%';Working tables for this task. Grading also uses other datasets with the same schema.
| id | name | category | price | stock |
|---|---|---|---|---|
| 1 | Book Light | books | 12 | 8 |
| 2 | Bowl | home | 20 | 4 |
| 3 | Lamp | home | 30 | 2 |
| 4 | Notebook | books | 10 | 12 |
| 5 | Box | NULL | 5 | 0 |
| 6 | Book Ocean | books | 20 | 1 |
| 7 | Mug | home | 30 | 3 |
| 8 | Pen | books | 19.99 | 7 |
| 9 | Cable | tools | 20.01 | 5 |
| 10 | Clip | tools | 9.99 | 3 |
| 11 | Fan | home | 30.01 | 1 |
| 12 | Book Edge | books | 20.01 | 2 |
| id | name | city |
|---|---|---|
| 1 | Mira | Sofia |
| 2 | Niko | Varna |
| 3 | Iva | Sofia |
| 4 | Alex | NULL |
| 5 | Boris | Plovdiv |
| 6 | Lena | Burgas |
| id | customer_id | total |
|---|---|---|
| 1 | 1 | 20 |
| 2 | 1 | 30 |
| 3 | 2 | 10 |
| 4 | 3 | 0 |
| 5 | 6 | 40 |
Expected columns: name · row order is not required
Expected result (displayed data):
Loading…LIKE compares text against a pattern. % matches any number of characters; _ matches one. PostgreSQL LIKE is case-sensitive. ILIKE is a PostgreSQL-specific case-insensitive variant; this lesson uses LIKE.
QUERY STANDBY
›