Sample Header Ad - 728x90

I would like to get a unique based on email address (MySQL)

0 votes
2 answers
213 views
I can work on basic queries and have been having a bit of trouble the way Wordpress stores their database information. The below query I have been using to download all form submissions for contests that we run. I usually download the results and then sort what I need to using excel or google sheets. Our last bunch of contests have had a lot of submissions, and I would like to take the following query and take it one step further : SELECT b.id, b.date_created, a.lead_id, a.form_id, max(case when a.field_number = 13 then value end) as FirstName, max(case when a.field_number = 14 then value end) as LastName, max(case when a.field_number = 15 then value end) as Address, max(case when a.field_number = 16 then value end) as Address2 , max(case when a.field_number = 17 then value end) as City, max(case when a.field_number = 18 then value end) as Province, max(case when a.field_number = 19 then value end) as PostalCode, max(case when a.field_number = 20 then value end) as Country, max(case when a.field_number = 4 then value end) as PhoneNumber, max(case when a.field_number = 3 then value end) as EmailAddress, max(case when a.field_number = 44 then value end) as Question, max(case when a.field_number LIKE 42.1 then value end) as ClientNewsletter, max(case when a.field_number LIKE 27.1 then value end) as LocalNewsletter FROM wp_rg_lead_detail a LEFT JOIN wp_rg_lead b ON a.lead_id = b.id WHERE a.form_id = 45 GROUP BY a.lead_id; This gets me my full list of entries. I would like to be able to generate three more results. This current result I would like to get unique entries by **EmailAddress** The two new lists I would like are based on whether **ClientNewsletter** is selected, as well as **LocalNewsletter**. Any help is appreciated.
Asked by kaykills (1 rep)
Jan 8, 2019, 03:14 PM
Last activity: Jun 15, 2025, 02:04 AM