sql使用更新

标签 sql database postgresql

我使用 pgsql,现在需要更新一列,在每个单元格中添加“.jpg”。

UPDATE image SET image_tag= image_location + '.jpg'::character varying;

但它显示

ERROR: operator does not exist: character varying + character varying LINE 1: UPDATE image SET image_tag= image_location + '.jpg'::charact... ^

HINT: No operator matches the given name and argument type(s). You might need to add explicit type casts.

错误

那么怎么解决呢。谢谢!!!

最佳答案

据我所知,PostgreSQL 使用 || 进行连接,而不是 +

9.4: String Functions and Operators

UPDATE image SET image_tag = image_location || '.jpg'

关于sql使用更新,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11029867/

相关文章:

database - 数据库和数据源的区别

php - 在 where 子句中使用日期,MYSQLI

json - 将bytea插入postgresql json类型

sql - 在查询中使用 VARCHAR 列的大小是否重要

python - SQLAlchemy 列类型比较

php - 将特殊字符插入数据库

sql - 不能更改 PostgreSQL 中 View 或规则使用的列的类型

SQL 连接两个具有不同列数的查询

mysql - 使用多个数据库结果执行 MySQL replace into select 死锁

sql - 入境验证?