= needs the whole text to match. LIKE matches a pattern, where % stands for any number of characters (even none) and _ for exactly one. Products whose name starts with "Rain":
SELECT name
FROM products
WHERE name LIKE 'Rain%';
Returns
name
----------
Rain boots
Raincoat
(2 rows)
'%book%' means "book" anywhere in the text, and '%s' means ending in s:
SELECT name
FROM products
WHERE name LIKE '%s';
Returns
name
----------
Rain boots
Binoculars
(2 rows)
In SQLite, LIKE ignores capital letters for plain English letters, so 'rain%' would find the same rows. PostgreSQL's LIKE doesn't ignore them and it has ILIKE for that. When it matters, make both sides the same case first, which works everywhere: LOWER(name) LIKE 'rain%'.
Functions take a value in brackets and give back a new one. UPPER and LOWER change the case, and LENGTH counts the characters:
SELECT name, UPPER(name), LENGTH(name)
FROM customers
WHERE city = 'Boston';
Returns
name | UPPER(name) | LENGTH(name)
-----+-------------+-------------
Dev | DEV | 3
Gus | GUS | 3
(2 rows)
|| (two upright bars) joins pieces of text together. SQL Server uses + instead, and MySQL uses the CONCAT() function. If any piece is NULL, the whole result is NULL.
SELECT name || ' lives in ' || city
FROM customers
WHERE city = 'Denver';
Returns
name || ' lives in ' || city
----------------------------
Ben lives in Denver
Eve lives in Denver
(2 rows)
A few more you'll see: TRIM(x) takes spaces off both ends, REPLACE(x, 'a', 'b') swaps every a for b, and SUBSTR(x, 1, 3) takes three characters starting from the first.