Tuesday, March 3, 2026

How to add multiple records with insert query in MYSQL

   INSERT INTO new_registration

(

`Ownership_Category`,

`Is_Govt_Org`,

`Title_Category`,

`Nationality`,

`Owner_Name`,

`Owner_Pan_Card`,

`Upload_pan_card_Document`,

`Mobile_No`,

`Email_ID`,

`PinCode`,

`State`,

`District`,

`City`,

How to add multiple rows in MySQL with for loop with stored procedure

 -- 1. Change the statement delimiter

DELIMITER $$

DROP PROCEDURE IF EXISTS insert_data_loop;

-- 2. Create the stored procedure

CREATE PROCEDURE insert_data_loop()

BEGIN

    DECLARE i INT DEFAULT 1; -- Declare a variable for the loop counter

    DECLARE max_value INT DEFAULT 50; -- Set the loop limit


    -- Start the WHILE loop

    WHILE i <= max_value DO

        -- 3. The INSERT query inside the loop

         SET i = i + 1;

        INSERT INTO new_registration

(

`Ownership_Category`,

`Is_Govt_Org`,

`Title_Category`,

`Nationality`,

`Owner_Name`,

`Owner_Pan_Card`,

`Upload_pan_card_Document`,

`Mobile_No`,

`Email_ID`,

`PinCode`,

`State`,

`District`,

`City`,

`Address`,

`DOB`,

`Upload_DOB_Certificate`,

`GST_No`,

`Upload_GST_Certificate`)

VALUES

(

'Individual',

1,

'News Paper',

'Indian',

'Yash Kapoor','45YYH87Y','Documents/test1.jpg',

457851,'test@test.com',

110022,'Haryana',

'Sonepat','Sonepat','Jangpura, Delhi',

' 15/01/1945', 'Documents/test1.jpg' ,

'JHJDFHJDF8787DF',

'Documents/test1.jpg');

        

        -- Increment the counter

       

    END WHILE;

END $$


-- 4. Reset the delimiter

DELIMITER ;


-- 5. Call the procedure to run the insert loop

CALL insert_data_loop();


-- Optional: verify the results

SELECT * FROM new_registration;


Note:- You cannot use for loop without Creating stored procedure.


How to add auto increment in column in MySQL

 https://stackoverflow.com/questions/33602936/mysql-workbench-auto-increment-disabled

How to add auto date in column in MySQL

 NOW() 

 CURRENT_DATE

CURRENT_TIMESTAMP 


in Default/Expression Column

Insert query in MYSQL - with now() - with update date

  INSERT INTO `test`.`new_registration`

(

`Ownership_Category`,

`Is_Govt_Org`,

`Title_Category`,

`Nationality`,

`Owner_Name`,

`Owner_Pan_Card`,

`Upload_pan_card_Document`,

`Mobile_No`,

`Email_ID`,

`PinCode`,

`State`,

`District`,

`City`,

`Address`,

`DOB`,

`Upload_DOB_Certificate`,

`GST_No`,

`Upload_GST_Certificate`)

VALUES

(

'Individual',

1,

'News Paper',

'Indian',

'Yash Kapoor','45YYH87Y','Documents/test1.jpg',

457851,'test@test.com',

110022,'Haryana',

'Sonepat','Sonepat','Jangpura, Delhi',

' 15/01/1945', 'Documents/test1.jpg' ,

'JHJDFHJDF8787DF',

'Documents/test1.jpg');