简体   繁体   中英

Sequelize concat in where clause?

I'm trying to do this in sequelize

SELECT * FROM tbl_person as p,tbl_employee as e
WHERE CONCAT(p.first_name,' ',last_name) = full_name;

how can I convert it in sequelize javascript?

thank you in advance.

I've never used sequelize before, but after glancing at the documentation, couldn't you use Sequelize.fn(...) ?

Model.findAll({
    where: Sequelize.where(
      Sequelize.fn("CONCAT",
        Sequelize.col("first_name"),
        " ",
        Sequelize.col("last_name")
      ),
      {
        eq: Sequelize.col('full_name')
      }
    )
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM