我从表中返回三行,如下所示:
select ID
from service
结果:
ID
--
1
2
3
如何返回如下输出:
count | IDs
-------+----------
3 | 1,2,3
答案 0 :(得分:1)
希望这会有所帮助
addNote() {
const {state} = this.props.navigation;
axios.post('https://ngc-todo.herokuapp.com/api/tasks', {
userId: state.params.user,
status: this.state.done,
task: this.state.toDoInput,
dueDate: this.state.dueDate,
category:this.state.selectCate
}).then(function(response) {
console.log(response)
return response.data;
if (response.data.success == true) {
() => this.state.toDoList.push({
taskId:response.data.data._id,
note: this.state.toDoInput,
date: this.state.dueDate,
status: this.state.done,
category: this.state.selectCate
});
console.log(this.state.toDoList)
this.setState({ toDoList: this.state.toDoList });
} else {
Alert.alert(response.data.message)
}
});
}
答案 1 :(得分:0)
如果您打算使用subquery
功能,那么您无需select count(1) count,
stuff(
(select ','+cast(id as varchar) from table for xml path('')),
1,1,'') Ids
from table
来计算ID数
npm install source-map@latest --save