Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

267
Views
How to update table columns that are stored as rows?

I am first time trying to update plugin data in wordpress database. I am using Advanced CF7 DB plugin for storing contact form 7 data. For updating the column I dont know whether pivot is required or there is anyother way to achieve this. Have searched but found two tables using pivot. I want to update data in same table just the columns are in rows. Dont know how to do this. Data is stored in below format:

  | id | cf7_id | data_id | name            | value       
  +----+--------+---------+-----------------+------------------
  |  9 |   4561 |       2 | uid             | 60eabb2c20021    
  | 10 |   4561 |       2 | emailId         | axxxxx@gmail.com 
  | 11 |   4561 |       2 | clicked_on_link | No               
  | 12 |   4561 |       2 | orderNos        | Miscommunication 
  | 13 |   4561 |       2 | submission_id   | 177              
  +----+--------+---------+-----------------+------------------

I want to update column clicked_on_link= Yes where uid= 60eabb2c20021. uid will be passed from url parameter.

 | 11 |   4561 |       2 | clicked_on_link | Yes      

I want this query in php-sql form so that I can include this in code.I have tried following query which I know is wrong but tried atleast:

update wp_cf7_vdata_entry as b1,
(select data_id,MAX(CASE WHEN name='uid' THEN value ELSE NULL END) AS 
uid,
MAX(CASE WHEN name='email_id' THEN value ELSE NULL END) AS email_id,
MAX(CASE WHEN name='clicked_on_link' THEN value ELSE NULL END) AS 
clicked_on_link 
from wp_cf7_vdata_entry group by data_id) as b2 
set b2.clicked_on_link='Yes'
where b1.data_id=b2.data_id 
and b2.uid=60ea1e95190ee;
over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

You can use join:

update wp_cf7_vdata_entry e join
       wp_cf7_vdata_entry e2
       on e.data_id = e2.data_id
    set e2.value = 'yes'
    where e.name = 'uid' and e.value = '60eabb2c20021' and
          e2.name = 'clicked_on_link';

Note: I'm not sure if cf7_id is relevant for the join condition, but your code only uses data_id.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!