You are on page 1of 1

-- 01 The SELECT statement

-- world.db
SELECT
SELECT
SELECT
SELECT
SELECT
SELECT

* FROM Country;
* FROM Country ORDER BY Name;
Name, LifeExpectancy FROM Country ORDER BY Name;
Name, LifeExpectancy AS 'Life Expectancy' FROM Country ORDER BY Name;
'Hello, World';
COUNT(*) FROM Country;

-- 02 Selecting Rows
-- world.db
SELECT Name, Continent, Region FROM Country;
SELECT Name, Continent, Region FROM Country WHERE Continent = "Europe";
SELECT Name, Continent, Region FROM Country WHERE Continent = "Europe" LIMIT 5;
-- 02 Selecting Rows
-- world.db
SELECT * FROM Country ORDER BY Code LIMIT 5;
SELECT Name, Code, Region, Population FROM Country ORDER BY Code LIMIT 5;
SELECT Name AS Country, Code AS ISO, Region, Population AS Pop FROM Country ORDE
R BY Code LIMIT 5;
-- 03 Counting Rows
-- world.db
SELECT
SELECT
SELECT
SELECT
e' ;

COUNT(*)
COUNT(*)
COUNT(*)
COUNT(*)

FROM
FROM
FROM
FROM

Country;
Country WHERE Population > 1000000;
Country WHERE Population > 100000000;
Country WHERE Population > 100000000 AND Continent = 'Europ

-- 03 Inserting Data
-- test.db
SELECT
INSERT
, '123
INSERT
;

* FROM Customer;
INTO Customer (name, address, city, state, zip) VALUES ('Fred Flintstone'
Cobblestone Way', 'Bedrock', 'CA', '91234');SELECT * FROM Customer;
INTO Customer (name, city, state) VALUES ('Jimi Hendrix', 'Renton', 'WA')

-- 04 Updating Data
-- test.db
SELECT
UPDATE
UPDATE
;
UPDATE

* FROM Customer;
Customer SET Address = '123 Music Avenue', Zip = '98056' WHERE id = 5;
Customer SET Address = '2603 S Washington St', Zip = '98056' WHERE id = 5
Customer SET Address = NULL, Zip = NULL WHERE id = 5;

-- 05 Deleting Data
-- test.db
SELECT
DELETE
DELETE
SELECT

* FROM Customer WHERE id = 4;


from Customer WHERE id = 4;
from Customer WHERE id = 5;
* FROM Customer;

You might also like