25

I'm trying to make a simple update query on postgresql. I don't really understand the error as there is no boolean value or column type. Here is the log :

cat=> UPDATE categories SET epekcategoryid='27af8b1e-c0c9-4084-8304-256b2ae0c8b2' and epekparentcategoryid='root' WHERE categoryId='281' and siteid='0' and categoryparentid='-1';
ERROR:  invalid input syntax for type boolean: "27af8b1e-c0c9-4084-8304-256b2ae0c8b2"
LINE 1: UPDATE categories SET epekcategoryid='27af8b1e-c0c9-4084-830...

The table config :

cat=> \d categories;
                Table "public.categories"
        Column        |         Type          | Modifiers 
----------------------+-----------------------+-----------
 categoryid           | character varying(32) | 
 categoryname         | text                  | 
 siteid               | integer               | 
 categoryparentid     | character varying(32) | 
 status               | integer               | default 0
 epekcategoryid       | text                  | 
 epekparentcategoryid | text                  | 
 categorylevel        | character varying(37) | 
 categoryidpath       | character varying(37) | 
2
  • WHERE categoryId='281' and siteid=0 and categoryparentid='-1'; Commented Nov 21, 2012 at 14:59
  • UPDATE categories SET epekcategoryid='27af8b' and epekparentcategoryid='root' WHERE categoryId='281' and siteid=0 and categoryparentid='-1'; is not working either Commented Nov 21, 2012 at 15:02

1 Answer 1

62

Try:

UPDATE categories 
SET epekcategoryid='27af8b1e-c0c9-4084-8304-256b2ae0c8b2',
    epekparentcategoryid='root' 
WHERE categoryId='281' 
  and siteid='0' 
  and categoryparentid='-1';

You must separate fields in SET part with "," , not with "AND"

Sign up to request clarification or add additional context in comments.

3 Comments

Common mistake indeed; using AND inside the SET part of an UPDATE query. Gives unusual errors like this.
mysql was the bad teacher :) though is a bit weird that we don't use "AND" after SET but we use after "WHERE"
@mihai It isnt weird, if you think about it. AND is an operator. Like +, - or *. In WHERE clause it is true AND false like 3 + 5, but in SET it becomes weird var1 = true AND var2 = 3.

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.