0

I need to update DATA value in column "InstalDate" with current date for ID < 450 and update with DATE='2017-05-05' for the rest of table records and it need to be done in one command, so how to do it in one command?

I managed to do it but only for ID < 450 and don't know how to add second condition in one command.

UPDATE tabela SET InstalDate= NOW() WHERE ID<450;

0

3 Answers 3

1

could using a case in values to assign

UPDATE tabela 
SET InstalDate = case when ID <450 then  NOW() else '2017-05-05' end 
Sign up to request clarification or add additional context in comments.

Comments

0

Adding conditions in UPDATE query is really simple you can simply use

UPDATE tabela SET InstalDate= NOW() WHERE ID<450 AND username='admin';

username='admin' is an example with an AND operator you change column name and its value

Comments

0
IF ID<450
    UPDATE tabela SET InstalDate= NOW()
ELSE
    UPDATE tabela SET InstalDate= '2017-05-05'

can you try this

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.