Postgres - 更新表中的多个列

时间:2018-03-09 07:52:35

标签: sql postgresql

我在更新表中的多个列时遇到错误。这是我的代码:

UPDATE
  products
SET
  updated_at = 1520581005920, products."categoryId" = t."categoryId"
FROM
  (VALUES (1,2),(3,4)) AS t (id,categoryId)
WHERE
  products.id = t.id AND
  products.store = 1
RETURNING
  products.id,
  products.title,
  products.status,
  products.condition,
  products."productInfo",
  products.price,
  products.note,
  products.created_at,
  products.updated_at

错误是:operator doesn't exist: integer = record。我该如何解决?

使用Knex.js创建表的代码:

await db.schema.createTable('products', function (table) {
  table.increments()
  table.string('title').notNullable()
  table.enu('status', ['sold', 'ordered', 'in-stock']).notNullable()
  table.enu('condition', ['used', 'new']).notNullable()
  table.text('productInfo').defaultTo(null)
  table.decimal('price').notNullable()
  table.text('note').defaultTo(null)
  table.bigInteger('created_at').notNullable()
  table.bigInteger('updated_at').notNullable()
  table.integer('categoryId').references('categories.id').notNullable()
  table.integer('store').references('stores.id').notNullable()
})

0 个答案:

没有答案
相关问题