Created
November 11, 2019 12:51
-
-
Save remcotolsma/6566a5503c015a71c500023c0f533c47 to your computer and use it in GitHub Desktop.
Query Gravity Forms entries of specific form and some extra meta values.
This file contains 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 | |
entry.id AS entry_id, | |
entry.date_created AS entry_created_on, | |
entry.form_id AS form_id, | |
form.title AS form_title, | |
user.display_name AS user_display_name, | |
emtry_meta_km.meta_value AS number_kilometers, | |
emtry_meta_office_id.meta_value AS office_id, | |
emtry_meta_date.meta_value AS period, | |
office.code AS office_code, | |
office.name AS office_name | |
FROM | |
wp_gf_entry AS entry | |
LEFT JOIN | |
wp_gf_form AS form | |
ON entry.form_id = form.id | |
LEFT JOIN | |
wp_users AS user | |
ON entry.created_by = user.ID | |
LEFT JOIN | |
wp_gf_entry_meta AS emtry_meta_km | |
ON ( | |
emtry_meta_km.entry_id = entry.id | |
AND | |
emtry_meta_km.meta_key = '1' | |
) | |
LEFT JOIN | |
wp_gf_entry_meta AS emtry_meta_office_id | |
ON ( | |
emtry_meta_office_id.entry_id = entry.id | |
AND | |
emtry_meta_office_id.meta_key = 'lookup_office_id' | |
) | |
LEFT JOIN | |
wp_gf_entry_meta AS emtry_meta_date | |
ON ( | |
emtry_meta_date.entry_id = entry.id | |
AND | |
emtry_meta_date.meta_key = 'lookup_year' | |
) | |
LEFT JOIN | |
wp_lookup_offices AS office | |
ON emtry_meta_office_id.meta_value = office.id | |
WHERE | |
entry.form_id = 6 | |
; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment