I have a SELECT statement like SELECT * FROM table where id=? and key IN (?,?..?)
SELECT * FROM table where id=? and key IN (?,?..?)
. For INSERT,UPDATE we have this batchWithParams, how can I do this for SELECT. I am using JDBC driver for MySQL database. The array list is like so,
BATCH [[100,4,11], [150,4,12]]
Why not just convert the ArrayList into String? Like this:
suspend fun getUsersByEmail(emails: Iterable<String>): List<User> {
return mysqlPool.getConnectionAwait().use { conn ->
conn.query(
"""
SELECT * FROM users
WHERE email IN (${emails.joinToString(separator = ", ") { "'$it'" }})
"""
).executeAwait().map { row ->
User(
row.getLong("id"),
row.getString("email")
)
}
}
}
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.