Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit b43b66c

Browse files
Understanding EXISTS
1 parent ce3bdd9 commit b43b66c

File tree

3 files changed

+31
-0
lines changed

3 files changed

+31
-0
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
SELECT first_name, last_name
2+
FROM customers
3+
WHERE email = 'max@test.com';
4+
5+
SELECT EXISTS(
6+
SELECT first_name, last_name
7+
FROM customers
8+
WHERE email = 'manu@test.com'
9+
);
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
CREATE TABLE customers(
2+
id INT PRIMARY KEY AUTO_INCREMENT, -- MySQL syntax
3+
-- id SERIAL PRIMARY KEY, --PostgreSQL syntax
4+
first_name VARCHAR(200),
5+
last_name VARCHAR(200),
6+
email VARCHAR(200)
7+
);
8+
9+
CREATE TABLE orders(
10+
id INT PRIMARY KEY AUTO_INCREMENT, -- MySQL syntax
11+
-- id SERIAL PRIMARY KEY, --PostgreSQL syntax
12+
amount_billed NUMERIC(5, 2),
13+
customer_id INT REFERENCES customers
14+
);
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
INSERT INTO customers(first_name, last_name, email)
2+
VALUES
3+
('Max', 'Schwarz', 'max@test.com'),
4+
('Manu', 'Lorenz', 'manu@test.com'),
5+
('Julia', 'Meyers', 'juli@test.com');
6+
7+
INSERT INTO orders(amount_billed, customer_id)
8+
VALUES (48.99,1), (27.45, 2), (19.49, 1), (8.49, 3);

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /