How to Increase or Decrease the price of all products in the table using SQL.

Here, the main focus is to update the field (here PRICE field ) value by adding some number or subtracting a number or adding a percentage amount directly in the TABLE using SQL command.

Note: When You are Going to Execute this command, I prefer you to keep a backup of your data. Sometimes after Executing a wrong command by mistake, as a effect may be your whole data be lost or that particular FIELD’s data be lost.

Here, TABLE NAME = ‘product’ and TABLE FIELD = ‘price’

# Update the price by 10% of the price for product=1

UPDATE `product` SET `price` = ROUND(`price` * (0.1), 0) WHERE `id` =1
# Update the price by Adding 10% of the price for product=1.
# New price will be, Price = price + (price * 10%)

UPDATE `product` SET `price` = `price` + ROUND(`price` * (0.1), 0) WHERE `product_id` =1
# Update the price by decreasing the existing price by 10% for product id=1.

UPDATE `product` SET `price` = (`price` - ROUND(`price` * (0.1), 0)) WHERE `product_id` =1

If you have any Query regarding this or have any Suggestion, please comment below.

What’s the difference between MyISAM and InnoDB?

What’s the difference between MyISAM and InnoDB?

MYISAM:

  1.  MYISAM supports Table-level Locking
  2. MyISAM designed for need of speed
  3. MyISAM does not support foreign keys hence we call MySQL with MYISAM is DBMS
  4. MyISAM stores its tables, data and indexes in diskspace using separate three different files. (tablename.FRM, tablename.MYD, tablename.MYI)
  5. MYISAM not supports transaction. You cannot commit and rollback with MYISAM. Once you issue a command it’s done.
  6. MYISAM supports fulltext search
  7. You can use MyISAM, if the table is more static with lots of select and less update and delete.

INNODB:

  1. InnoDB supports Row-level Locking
  2. InnoDB designed for maximum performance when processing high volume of data
  3. InnoDB support foreign keys hence we call MySQL with InnoDB is RDBMS
  4. InnoDB stores its tables and indexes in a tablespace
  5. InnoDB supports transaction. You can commit and rollback with InnoDB