-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy path03_pets.sql
41 lines (39 loc) · 916 Bytes
/
03_pets.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
-- Information about pets is kept in two separate tables:
--
-- TABLE dogs
-- id INTEGER NOT NULL PRIMARY KEY,
-- name VARCHAR(50) NOT NULL
--
-- TABLE cats
-- id INTEGER NOT NULL PRIMARY KEY,
-- name VARCHAR(50) NOT NULL
--
-- Write a query that select all distinct pet names.
--
-- Suggested testing environment:
-- http://sqlite.online/
-- Example case create statement:
-- CREATE TABLE dogs (
-- id INTEGER NOT NULL PRIMARY KEY,
-- name VARCHAR(50) NOT NULL
-- );
--
-- CREATE TABLE cats (
-- id INTEGER NOT NULL PRIMARY KEY,
-- name VARCHAR(50) NOT NULL
-- );
--
-- INSERT INTO dogs(id, name) values(1, 'Lola');
-- INSERT INTO dogs(id, name) values(2, 'Bella');
-- INSERT INTO cats(id, name) values(1, 'Lola');
-- INSERT INTO cats(id, name) values(2, 'Kitty');
--
-- Expected output (in any order):
-- name
-- -----
-- Bella
-- Kitty
-- Lola
select name from dogs
union
select name from cats;