Skip to content

Instantly share code, notes, and snippets.

@zeke
Last active November 18, 2021 06:07
Show Gist options
  • Save zeke/de280d672ac5ab58a0612d3e9c134909 to your computer and use it in GitHub Desktop.
Save zeke/de280d672ac5ab58a0612d3e9c134909 to your computer and use it in GitHub Desktop.
# The predictions table is called models_prediction
# The users table is called users_user
# Select all predictions where the user id is equal to the user with username 'zeke'
SELECT * FROM models_prediction WHERE user_id = (SELECT id FROM users_user WHERE username = 'zeke');
# Count all predictions where the user id is equal to the user with username 'zeke'
SELECT COUNT(*) FROM models_prediction WHERE user_id = (SELECT id FROM users_user WHERE username = 'zeke');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment