我正在try 对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) | 

推荐答案

try :

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

必须用","分隔SET部分中的字段,而不是用"AND"

Postgresql相关问答推荐

将几个左连接合并为一个

Keycloak和PostgreSQL

PostGresql :正则表达式 Select 其中只有一个正斜杠的行

Postgres 函数 now() 返回不正确的时区偏移量

Upper() 不会大写重音字符

如何从元组列表中 Select 与多列匹配的行?

Postgres COPY FROM csv file-No such file or directory

Rails 3:在 Postgres 支持的 ActiveRecord 中使用 json 作为列类型时出现迁移错误

如何在 plpgsql 中使用记录类型变量?

你如何在postgresql中做mysqldump?

大型查询后 psycopg2 泄漏内存

Python PostgreSQL 模块.哪个最好?

Postgresql 中的 NOT EXISTS 子句

如何在 postgresql 交叉表中用零替换空值

如何使用 sql 或 phpPgAdmin 更改 PostgreSQL 数据库的数据库编码?

使用 Postgresql 在过滤器中制作 Sqlalchemy 使用日期

由于不支持身份验证类型 10,无法连接到 Postgres DB

如何在创建数据库时安装 Postgres 扩展?

postgresql中的移动平均线

pg_restore 目录错误