1

I have table with two columns Product1, Product2. I cant modify this table but i need id. So i want to create view with Id column.

    CREATE 
        ALGORITHM = UNDEFINED 
        DEFINER = `database`@`%` 
        SQL SECURITY DEFINER
    VIEW `products_view` AS
        SELECT 
            ID_INCREMENT_FUN() AS `ID`,
            `Products`.`Product1` AS `product1`
            `Products`.`Product2` AS `product2`
        FROM
            `Products`

I have a problem with increment function. I dont have any idea how store incremented value in funtion. This is my function.

CREATE DEFINER=`database`@`%` FUNCTION `ID_INCREMENT_FUN`() RETURNS int(11)
BEGIN
declare  i INT;
SET i = i+1;
RETURN i;
END
S3S
  • 24,809
  • 5
  • 26
  • 45
Amek
  • 11
  • 1

0 Answers0