Muhammad Husnain Tahir
Muhammad Husnain Tahir

Reputation: 1039

MySQL Query Problems for error ''

Hi all i have been writing a query and it is driving me crazy because it is giving me syntax error for ''

my query is

UPDATE test1 SET result = 
CASE WHEN formula = "p1+p2" THEN 2

the error is here on line 2 any help is highly appreciated.

Upvotes: 0

Views: 46

Answers (1)

Gordon Linoff
Gordon Linoff

Reputation: 1270201

A case should always have an end:

UPDATE test1
    SET result = (CASE WHEN formula = 'p1+p2' THEN 2 END);

This sets result to either "2" or NULL. You probably want:

UPDATE test1
    SET result = 2
    WHERE formula = 'p1+p2';

As a general rule, use single quotes for string constants. This is the ANSI standard.

Upvotes: 2

Related Questions