2

I have three query and I would like to have a single one. These is my query:

UPDATE tab1 SET a='' WHERE id=3;
UPDATE tab2 SET b='' WHERE id=9;
UPDATE tab3 SET c='' WHERE id=5;

1 Answer 1

3

You can try below code:

UPDATE tab1, tab2, tab3
SET tab1.a = '', tab2.b = '',tab3.c = ''
WHERE tab1.id = 3 AND tab2.id = 9 AND tab3.id = 5;

UPDATE:

As per mentioned by OP, the code not working for Mysql 5.5, below code added

UPDATE tab1 a 
  INNER JOIN tab2 b ON (a.id = b.id)
  INNER JOIN tab3 c ON (a.id = c.id)
SET tab1.a = '', tab2.b = '', tab3.c = ''
WHERE a.id = 3 AND tab2.id = 9 AND tab3.id = 5;
Sign up to request clarification or add additional context in comments.

2 Comments

@FrancescoG.,make sure you do used Aliases of every table with there respective Column names as; tab1.a ,tab2.b, tab3.c
... work perfectly for mysql 5.6 but not for mysql 5.5! Any suggest?

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.