1

i have table of cars and i need to put constraint,

if car.speed<1200 then price<=90000

I try this:

ALTER TABLE CARS ADD CONSTRAINT price_speed_chk CHECK( CASE WHEN speed <1200 THEN price<=90000 ); 

it's doesn't work.

who can help ? thanks!

1 Answer 1

3

You are using CASE completely a wrong way. If you need a check with that logic, you can simply use some boolean operators:

ALTER TABLE CARS ADD CONSTRAINT price_speed_chk CHECK(speed >= 1200 OR price<=90000 ); 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.