syed
syed

Reputation: 289

Update all rows in a MySQL table using single query

I am wondering from 2 days but didn't get any suitable solution for my problem. I am working on a project and here I stuck on updating all rows of a MySQL table using single Update Query in PHP. Let's Suppose I have the table like given below

id |  heading  |  description
---------------------------
1    heading1    desc1

2    heading2    desc2

3    heading3    desc3

Now I want to update the heading, description fields using single update query. how will I loop the form for this ? can somebody suggest the easy and most efficient way to do this.

Upvotes: 0

Views: 7266

Answers (1)

ScaisEdge
ScaisEdge

Reputation: 133360

could be a simple updated

update my_table  
set heading  = 'my_value1',
    description = 'my_value2';

eventually you can add some where for proper filter

update my_table  
set heading  = 'my_value1',
    description = 'my_value2'
where heading = 'a_value';

Upvotes: 3

Related Questions