gpt4 book ai didi

sql - 我能做什么? Sequelize isnull

转载 作者:行者123 更新时间:2023-12-03 22:25:47 25 4
gpt4 key购买 nike

[表] USER_INFO

user_id  |  user_name
a123 | facebook
b123 | google
c123 | NULL

[询问]
select isnull(user_name, user_id) as user_name from USER_INFO

[结果]
user_name
facebook
google
c123

[ Sequelize ] ???????
User.findAll({attributes: [
user_id
,user_name
]
});

我想要相同的结果,查询 = Sequelize ..

最佳答案

尝试使用 where 运算符:

User.findAll({where:{
user_name:{[Op.ne]:null}
},{attributes: [user_id,user_name]
}});

关于sql - 我能做什么? Sequelize isnull,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61903461/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com