Skip to content

Instantly share code, notes, and snippets.

@FromMeloriWithLove
Created November 17, 2023 00:46
Show Gist options
  • Save FromMeloriWithLove/9026f7af98c6ea2e9fba86a8fd1237d9 to your computer and use it in GitHub Desktop.
Save FromMeloriWithLove/9026f7af98c6ea2e9fba86a8fd1237d9 to your computer and use it in GitHub Desktop.
1)
SELECT user_id, nick, age, education.name, drinking.name, smoking.name
FROM users
JOIN education ON users.id_education = education.id
JOIN drinking ON users.my_drink = drinking.id
JOIN smoking ON users.my_smoke = smoking.id
WHERE education.name = 'высшее' AND drinking.name = 'не пью вообще' AND smoking.name = 'не курю'
2)
SELECT user_id, nick, age, eyescolor.name, haircolor.name, gender.name
FROM users
JOIN eyescolor ON users.eyes_color = eyescolor.id
JOIN haircolor ON users.hair_color = haircolor.id
JOIN gender ON users.sex = gender.id
WHERE eyescolor.name = 'голубые' AND haircolor.name = 'блонд' AND gender.name = 'женский'
UNION
SELECT user_id, nick, age, eyescolor.name, haircolor.name, gender.name
FROM users
JOIN eyescolor ON users.eyes_color = eyescolor.id
JOIN haircolor ON users.hair_color = haircolor.id
JOIN gender ON users.sex = gender.id
WHERE eyescolor.name = 'карие' AND haircolor.name = 'брюнет' AND gender.name = 'мужской'
3)
SELECT users.user_id, nick, age, framework.name, interes.name
FROM users
JOIN users_moles ON users_moles.user_id = users.user_id
JOIN moles ON moles.id = users_moles.moles_id
JOIN framework ON framework.id = users.id_framework
JOIN users_interes ON users_interes.user_id = users.user_id
JOIN interes ON interes.id = users_interes.interes_id
WHERE framework.name = 'информационные технологии'
4)
SELECT users.user_id, nick, age, kitchen.name
FROM users
JOIN users_languages ON users_languages.user_id = users.user_id
JOIN languages ON languages.id = users_languages.languages_id
JOIN kitchen ON kitchen.id = users.like_kitchen
WHERE kitchen.name = 'явно не кулинар' AND kitchen.name = 'готовлю, но никто не ест'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment