3

i got to execute loads of the following queries

UPDATE translations SET translation = (SELECT description FROM content WHERE id = 10) WHERE id = 1;

Now, i use the load data infile to do inserts and replacements but what i want in esense is to update just 1 field for each row in that table with out messing with the keys. What could be the syntax for this, note that the queries affect existing rows only.

Thanx

1 Answer 1

6
  • Use CREATE TEMPORARY TABLE to create a temporary table.
  • Then use LOAD DATA INFILE to populate that temporary table.
  • Then execute your UPDATE translations SET translation = ... to set the 1 field from a SELECT of the temporary table, JOINed with the real table. example syntax below:

    UPDATE realTable, tmpTable 
      SET realTable.price = tmpTable.price 
      WHERE realTable.key = tmpTable.key
    
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.