vendredi 1 mars 2019

Need to insert i products table from more than one tables with dynamic id

I have 3 tables users, products and temp_table. i have imported an xlsx file having 1,00,000 records in to temp_table. now i have to insert these records to products table. and here i have to save user_id from users table to products table as well. Note: user_id is dynamic(i.e. in xlsx file there is a column called email and I have created a new user for their email). so in products table user_id will be dynamically inserted. I have used below query, but it is taking too much time. and sometimes my MySQL get locked.

INSERT INTO products
        (user_id,
        brand_id,
        points_discount,
        amount,
        sub_total,
        added_on)
        SELECT users.user_id, 
            brand_id,
            discount,
            amount,
            sub_total,
            added_on
        FROM temp_table
        INNER JOIN users 
        ON email = users.email;



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2EE8TuO
via IFTTT

Aucun commentaire:

Enregistrer un commentaire