PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Wednesday, February 2, 2022

[FIXED] Update and append to all items in a specific column

 February 02, 2022     mysql, phpmyadmin, sql, sql-update     No comments   

Issue

How do I append a character to all items `purchase_id' here is a manual example of what I want...

SELECT * 
FROM `loadable_link` 
WHERE `product_sku` = '2101-R' 
ORDER BY `customer_id` DESC

Then select from purchased_id and append a '0' to all purchased ID's

UPDATE `loadable_link` SET `purchased_id` = '11165690' 
WHERE `loadable_link`.`purchased_id` = 1116569;

Solution

You can update the table according to the condition in the original select statement.

If purchase_id is a number, you can multiply it by 10:

UPDATE `loadable_link`
SET    `purchase_id` = `purchase_id` * 10
WHERE  `product_sku` = '2101-R' 

If purchase_id is a string, you can concatenate a 0 to it:

UPDATE `loadable_link`
SET    `purchase_id` = CONCAT(`purchase_id`, '0')
WHERE  `product_sku` = '2101-R' 


Answered By - Mureinik
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing