Skip to content

Instantly share code, notes, and snippets.

@mikl
Created August 16, 2010 21:29
Show Gist options
  • Save mikl/527783 to your computer and use it in GitHub Desktop.
Save mikl/527783 to your computer and use it in GitHub Desktop.
-- Select the fields we need.
SELECT u.uid AS uid,
u.name AS username,
TRIM(n.title) AS real_name,
ctp.field_profile_nametag_value AS nametag_name,
ctp.field_profile_company_value AS company,
ctp.field_profile_drupal_value AS drupal_org_name,
ctp.field_profiler_do_uid_value AS drupal_org_uid,
ctp.field_profiler_twitter_value AS twitter_name,
ctp.field_profile_country_value AS country,
ctp.field_profile_attending_as_dg_value AS is_drupalganger,
ctp.field_staff_title_value AS staff_title
-- Base table is users
FROM users AS u
-- INNER JOIN to filter those who does not have the attendee role (rid=5)
INNER JOIN users_roles AS ur ON (u.uid = ur.uid AND ur.rid = 5)
-- LEFT JOIN to get the profile node.
LEFT JOIN node AS n ON (n.uid = u.uid AND n.status = 1 AND n.type = 'profile')
-- LEFT JOIN to get profile CCK fields
LEFT JOIN content_type_profile AS ctp ON (n.vid = ctp.vid)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment