如何使用别名选择列 [英] How do I select a column using an alias
本文介绍了如何使用别名选择列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何执行这样的 sql 查询?
How do I perform an sql query such as this?
SELECT column_name AS alias_name FROM table_name;
示例:我希望将first"列选为firstname"
Example: I want the column 'first' to be selected as 'firstname'
Table.findAll({
attributes: [id,"first"]
})
.then(function(posts) {
res.json(posts);
})
推荐答案
Table.findAll({
attributes: ['id', ['first', 'firstName']] //id, first AS firstName
})
.then(function(posts) {
res.json(posts);
});
这篇关于如何使用别名选择列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文