Created
March 15, 2010 10:13
-
-
Save willert/332705 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT | |
id, | |
id AS user_id, | |
username, | |
CASE user_privacy.person WHEN 2 THEN firstname END AS firstname, | |
CASE user_privacy.person WHEN 2 THEN surname END AS surname, | |
CASE user_privacy.person WHEN 2 | |
THEN UNIX_TIMESTAMP( user_profile.birthday ) END AS birthday, | |
CASE user_privacy.person WHEN 2 THEN DAY( user_profile.birthday ) | |
END AS birthday_dom, | |
CASE user_privacy.person WHEN 2 THEN MONTH( user_profile.birthday ) | |
END AS birthday_month, | |
UNIX_TIMESTAMP( joined_at ) AS joined_at, | |
UNIX_TIMESTAMP( last_page_view ) AS last_login, | |
CASE WHEN reference_day = 1 AND reference_week = 1 THEN | |
UNIX_TIMESTAMP( reference_date ) END AS training_start, | |
CASE user_privacy.person WHEN 2 THEN | |
CASE gender WHEN 'm' THEN 2 WHEN 'f' THEN 1 END | |
ELSE 0 | |
END AS gender, | |
CASE WHEN uri_for_avatar IS NULL THEN 0 ELSE 1 END AS has_photo, | |
CASE user_privacy.region WHEN 2 THEN | |
CASE WHEN opengeodb.geodb_coordinates.lat IS NOT NULL THEN | |
RADIANS( opengeodb.geodb_coordinates.lat ) | |
END | |
END AS lat, | |
CASE user_privacy.region WHEN 2 THEN | |
CASE WHEN opengeodb.geodb_coordinates.lon IS NOT NULL THEN | |
RADIANS( opengeodb.geodb_coordinates.lon ) | |
END | |
END AS lon | |
FROM | |
user | |
JOIN | |
user_profile USING( id ) | |
JOIN | |
user_privacy USING( id ) | |
JOIN | |
training_status USING( id ) | |
LEFT JOIN | |
opengeodb.geodb_coordinates ON ( loc_id = location ) | |
WHERE id >= 10 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment