2012-11-21 35 views
5

我想對postgresql做一個簡單的更新查詢。由於沒有布爾值或列類型,我不太瞭解該錯誤。 這裏是日誌:postgresql更新錯誤「錯誤:布爾類型的輸入語法無效:」

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... 

表配置:

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) |
+0

'WHERE categoryId ='281'and siteid = 0 and categoryp isntid =' - 1';' – wildplasser

+0

UPDATE categories SET epekcategoryid ='27af8b'and epekparentcategoryid ='root'WHERE categoryId ='281'and siteid = 0 and categoryparentid =' - 1'; – themihai

回答

21

嘗試:

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

您必須SET部分與 「,」 分離領域,不與 「AND

+2

確實無法正常工作;在'UPDATE'查詢的'SET'部分使用'AND'。給出這樣的不尋常的錯誤。 – pyrocumulus

+0

mysql是不好的老師:)雖然有點奇怪,我們不使用SET後的「AND」,但我們在「WHERE」之後使用 – themihai

+4

@mihai如果你考慮一下,這並不奇怪。 'AND'是一個操作員。像「+」,「-'或」*'。在'WHERE'子句中,它是'true&false',就像'3 + 5',但是在'SET'中變得很奇怪'var1 = true AND var2 = 3'。 –

相關問題