# SQL 速查表

# QUERYING SINGLE TABLE

SELECT *
FROM country;
SELECT id, name
FROM city;
SELECT name
FROM city
ORDER BY raging [asc];
SELECT name
FROM city
ORDER BY raing DESC;

# ALIASES

SELECT name AS city_name
FROM city;
SELECT co.name, ci.name
FROM city AS ci
JOIN country AS co
  ON ci.country_id = co.id

# FILTERING

SELECT name
FROM city
WHERE rating > 3;

Fetch names of cities that are neither Berlin nor Madrid:

SELECT name
FROM city
WHERE name != 'Berlin'
  AND name != 'Madrid';

# TEXT OPERATORS

SELECT name
FROM city
WHERE name LIKE 'P%'
   OR name LIKE '%s';