sql - MySQL Pivot a table where columns are in a row of their own -


I have a form of WordPress site using the ARFs plugin that receives names, emails and telephone numbers, But layout in a stupid database.

I have a MYSQL WordPress table like this:

  | Id | Entry_value | Field_id | Entry_ID | | 1 | John | 74 | 1 | | 2 | Smith | 75. 1 | | 3 | 555 1234 | 76 | 1 | | 4 | Jsmith@mail.com | 77 | 1 | | 5 | Sue | 74 | 2 | | 6 | Brown | 75. 2 | | 7 | 555 4321 | 76 | 2 | | 8 | Cyberline @mail dot | 77 | 2 |  

I am using another plugin export report to try and query this table and am receiving a report for all users who have filled out the form.

I format it like this:

  | ID | Name | Surname Email | Telephone | 1 | John | Smith | Jsmith@mail.com | 555 1234 | 2 | Sue | Brown | Sbrown @ mel com | 555 4321  

I have tried following the following by looking at some examples, but I am refunding the return of the tap. I need to filter it in any way and only smoke where the value Are there. Note: There are 2 additional fields in comparison to the above example, Interested and Prefecture:

  Get subscribed as view users (choose an .entry_id, a.field_id, case when field_id = '74 'In the case of first name, when field_id =' 75 'ends in the form of entry_value lastlam, then when the field_id =' 76 'is in the form of entry_value e-mail, case when field_id =' 78 'then ends as entry-value phone The case is when the field_id = '79' then enter_value InterestedIn as the end, case when field_id = '81' then the entry_type ends as the province from ch_arf_entry_values; Create View_subscribed_extended_pivot as a view (Enter the ID, First name, Last name, Email, Phone, Interested, Entry_ID, as the user from the Subscriber Group); SELECT * users_subscribed_extended_pivot; Can anyone help you ...   

You are missing, the maximum work done by the group

You do not need two views, you can do this in a view

  Select a .entry_id , Max (when case_id = Phone, Max (cases) as FirstName, Max (when case_id = 75 then Entry_WA ends and ends) in case of max (case when field_id = 76 then entry_view and end) When field_id = 78 then entry / different termination) Maximum (case when field_id = 79 entries / different terminations) InterestedIn, MAX (case_id = 81 then entry_value end) as a group by ch_arf_entry_values ​​a.entry_id  

Comments

Popular posts from this blog

java - Can't add JTree to JPanel of a JInternalFrame -

javascript - data.match(var) not working it seems -

javascript - How can I pause a jQuery .each() loop, while waiting for user input? -