【问题标题】:How to concat two columns from SQL Server using knex.js without using knex.raw()如何在不使用 knex.raw() 的情况下使用 knex.js 从 SQL Server 连接两列
【发布时间】:2021-01-30 11:25:12
【问题描述】:

我这里有一个示例代码。

有人可以在不使用knex.raw 的情况下将其翻译成 knex 吗?

SELECT DISTINCT (columna + '-' + columnb) AS column 
FROM table

【问题讨论】:

    标签: sql node.js distinct concat knexjs


    【解决方案1】:

    knex 有distinct

    const rows = await knex('table').distinct('columna', 'columnb')
    rows.map(row => `${columna}-${columnb}`)
    

    【讨论】:

      猜你喜欢
      • 2022-07-01
      • 2018-02-14
      • 1970-01-01
      • 2017-10-05
      • 1970-01-01
      • 1970-01-01
      • 2011-06-15
      • 2012-05-13
      • 1970-01-01
      相关资源
      最近更新 更多