Jump to content

Recommended Posts

Hi guys,

 

Say I got two tables,

  • Table1 - columns A, B, C, flag - approx 200 000 rows
  • Table2 - columns A, B, C - approx 20 000 rows

What I want to do is:

  • Update Table1
    Set flag = 1
    Where "at least one row from Table2 has the same entries in columns
    A, B and C"

Right now I am solving this with a "select distinct A, B, C from Table2" and transform this into a long where condition (with php). afterwards I apply the above update with this where condition. However this aproche needs about 5 minutes to run and I believe this could be much faster when I just know the right MySql command for this.

 

Can anyone help me?

 

cheers,

Peter

Link to comment
https://forums.phpfreaks.com/topic/273823-update-faster/
Share on other sites

The quickest way of doing something like inserting new rows/updating (replacing) existing rows for something like an inventory, is to use a multi-value REPLACE query -

REPLACE tbl_name (col_name,...) VALUES (value,...),(...),...

Edited by PFMaBiSmAd
Link to comment
https://forums.phpfreaks.com/topic/273823-update-faster/#findComment-1409130
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.