________ ___ ___ _____ ______ ________ ________ ________ _________ _______
|\ _____\\ \|\ \ |\ _ \ _ \|\ __ \|\ __ \|\ __ \|\___ ___\\ ___ \
\ \ \__/\ \ \ \ \ \ \ \\\__\ \ \ \ \|\ \ \ \|\ \ \ \|\ \|___ \ \_\ \ __/|
\ \ __\\ \ \ \ \ \ \ \\|__| \ \ \ \\\ \ \ _ _\ \ __ \ \ \ \ \ \ \_|/__
\ \ \_| \ \ \ \ \____\ \ \ \ \ \ \ \\\ \ \ \\ \\ \ \ \ \ \ \ \ \ \ \_|\ \
\ \__\ \ \__\ \_______\ \__\ \ \__\ \_______\ \__\\ _\\ \__\ \__\ \ \__\ \ \_______\
\|__| \|__|\|_______|\|__| \|__|\|_______|\|__|\|__|\|__|\|__| \|__| \|_______|
SELECT *
FROM users;
SELECT *
FROM users
WHERE id = {id};
SELECT *
FROM users
WHERE id IN (SELECT friend_id FROM friends WHERE user_id = {id});
SELECT *
FROM users
WHERE id IN (SELECT friend_id FROM friends WHERE user_id = {id});
INTERSECT
SELECT *
FROM users
WHERE id IN (SELECT friend_id FROM friends WHERE user_id = {otherId});
INSERT INTO users (email, login, name, birthdate)
VALUES ('test@email.ru', 'test_user', 'test user_name', '2000-10-13')) RETURNING id;
UPDATE users
SET email = 'test_update@email.ru',
login = 'test_user',
name = 'test user_name',
birthdate = TO_DATE('01022019', 'MMDDYYYY')
WHERE id = 'id';
INSERT INTO friends (user_id, friend_id)
VALUES ({id}, {friendId});
DELETE
FROM friends
WHERE (user_id = {id} AND friend_id = {friendId};
DELETE
FROM users
WHERE id = {id} CASCADE;
SELECT * FROM films;
SELECT *
FROM films AS f
WHERE f.id = {id};
INSERT INTO films (description, name, releaseDate, duration, mpaa_rate_id)
VALUES ('test_description', 'test_name', '2010-07-15', 120, 2) RETURNING id;
UPDATE films
SET description = 'new_description',
name = 'new_test_name',
releaseDate = '2010-07-15',
duration = 120,
mpaa_rate_id = 2
WHERE id = 'id';
INSERT INTO likes (film_id, user_id)
VALUES ({id}, {userId});
DELETE
FROM films
WHERE id = {id} CASCADE;
DELETE
FROM likes
WHERE film_id = {id} AND user_id = {userId};
INSERT INTO film_genre (film_id, genre_id)
VALUES (5, 2);