Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Update some records in the database table

I want to update two records from the age column in the table below, for this I use the following command:

enter image description here

UPDATE `persons` SET `Age` =( CASE WHEN FirstName = 'User 2' THEN 10 WHEN FirstName = 'User 3' THEN 12 END ) WHERE LastName = 'User'; 

According to the picture below, the rest of the age records are equal to null

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

enter image description here

Please guide me to solve this problem

>Solution :

use this query:

UPDATE `persons` SET `Age` = ( CASE WHEN FirstName = 'User 2' THEN 10 WHEN FirstName = 'User 3' THEN 12 ELSE Age END ) WHERE LastName = 'User'; 
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading