【发布时间】:2021-12-22 07:23:09
【问题描述】:
我想写以下查询
Select id from table1
使用 id 的结果集和
Select * from table2 where id in (resultset)
如何使用 Nodejs 和 MySQL 实现它。我是 Nodejs express 框架的初学者。
【问题讨论】:
标签: mysql node.js express asynchronous async-await
我想写以下查询
Select id from table1
使用 id 的结果集和
Select * from table2 where id in (resultset)
如何使用 Nodejs 和 MySQL 实现它。我是 Nodejs express 框架的初学者。
【问题讨论】:
标签: mysql node.js express asynchronous async-await
你可以使用字符串连接:
const query1 = "Select id from table1";
const query2 = `Select * from table2 where id in (${query1})`
或者只写嵌套查询:
const query = "Select * from table2 where id in (Select id from table1)"
【讨论】: