Skip to content

Instantly share code, notes, and snippets.

View bartubozkurt's full-sized avatar
🎯
Focusing

Bartu Bozkurt bartubozkurt

🎯
Focusing
View GitHub Profile
@bartubozkurt
bartubozkurt / count.sql
Created June 11, 2021 18:00
Find out the number of cities
SELECT COUNT(*) FROM city;
@bartubozkurt
bartubozkurt / operators_3.sql
Created June 11, 2021 17:54
Fetch name of cities that are in countries with IDs 1,4,7 or 8
SELECT name
FROM city
WHERE country_id IN (1,4,7,8);
@bartubozkurt
bartubozkurt / operators_2.sql
Created June 11, 2021 17:52
Fetch names of cities that don't miss a rating value
SELECT name
FROM city
WHERE rating is NOT NULL;
@bartubozkurt
bartubozkurt / operators.sql
Created June 11, 2021 17:50
Fetch names of cities that have a population between 500K and 5M
SELECT name
FROM city
WHERE population BETWEEN 500000 AND 5000000;
@bartubozkurt
bartubozkurt / text_operators_2.sql
Created June 11, 2021 17:46
Fetch names of cities that start with any letter followed by 'ublin' (like Dublin in Ireland or Lublin in Poland)
SELECT name
FROM city
WHERE name LIKE '_ublin';
@bartubozkurt
bartubozkurt / text_operators.sql
Created June 11, 2021 17:41
Fetch names of cities that start with a 'P' or end with an 's'
SELECT name
FROM city
WHERE name LIKE 'P%' OR name LIKE '%s';
@bartubozkurt
bartubozkurt / sql_!.sql
Created June 11, 2021 17:38
Fetch names of cities that are neither Berlin nor Madrid
SELECT name
FROM city
WHERE name != 'Berlin' AND name != 'Madrid';
@bartubozkurt
bartubozkurt / operators.sql
Created June 11, 2021 17:35
Fetch names of cities that have a rating above 3
SELECT name FROM city WHERE rating > 3;
@bartubozkurt
bartubozkurt / as_table.sql
Created June 11, 2021 17:29
With the AS expression, we can temporarily give short names to long and difficult to use table or field names
SELECT co.name, ci.name
FROM city AS ci
JOIN country AS co
ON ci.country_id = co.id;
@bartubozkurt
bartubozkurt / as_columns.sql
Created June 11, 2021 17:27
With the AS expression, we can temporarily give short names to long and difficult to use table or field names
SELECT name AS city_name FROM city;