How to run Trigger only on certain updates I have the following two tables:

CREATE TABLE IF NOT EXISTS `Product` (
    `ProductID` VARCHAR(16),
    `ProductName` TINYTEXT NOT NULL,
    `CategoryID` VARCHAR(3) REFERENCES Category (CategoryID)
    ON DELETE CASCADE ON UPDATE CASCADE,
    `ProductDescription` TEXT,
    `MRP` DOUBLE NOT NULL,
    `SellingPrice` DOUBLE NOT NULL,
    `ProductBrand` VARCHAR(30) NOT NULL,
    `Stock` INT(11) NOT NULL,
    PRIMARY KEY (`ProductID`)
);

CREATE TABLE IF NOT EXISTS `PriceDetails` (
    `ProductID` VARCHAR(16) REFERENCES Product (ProductID),
    `Time_Stamp` DATETIME NOT NULL,
    `Price` DOUBLE NOT NULL,
    PRIMARY KEY (`ProductID` , `Time_Stamp`)
);


And a trigger:

DELIMITER $$

    CREATE TRIGGER price_update 
        AFTER UPDATE ON Product
        FOR EACH ROW 
    BEGIN
    INSERT INTO PriceDetails
    values(
        NEW.ProductID,
        now(),
        NEW.SellingPrice);

    END$$
DELIMITER ;


This trigger runs every time the Product table is updated.

Now, I want to run this trigger only when the SellingPrice is updated in the Product table.
The trigger always "runs" -- but just because it runs doesn't mean it has to perform any action.  And a trigger that doesn't perform any action doesn't take very long, if you're concerned about efficiency.  

In your case, all you need is logic to compare NEW.SellingPrice to OLD.SellingPrice and only perform the INSERT action if the two values are not the same.

Note that a common error at this step is to assume that != is the correct operator to use when comparing old and new values, but this will bite you if the column is nullable, because null values are neither equal to nor not equal to any other value, including null itself (since null is not a value, even though I myself carelessly used the phrase "null values" earlier in this same sentence).  Even if the column isn't nullable now, it is probably still a good practice to use the null-safe comparison ("spaceship") operator &lt;=&gt; and negate the result with NOT, because &lt;=&gt; expresses the actual relationship we're trying to evaluate:

DELIMITER $$

CREATE TRIGGER price_update 
    AFTER UPDATE ON Product
    FOR EACH ROW 
BEGIN
  IF NOT (NEW.SellingPrice &lt;=&gt; OLD.SellingPrice) THEN
    -- this update has changed the value of SellingPrice 
    -- for the row that invoked this run of the trigger
    INSERT INTO PriceDetails
    values(
      NEW.ProductID,
      now(),
      NEW.SellingPrice);
  END IF; 

END $$
DELIMITER ;