mysql - 如何将流氓查询转换为Mysql?

标签 mysql mongodb scala

我发现了一个用Rogue编写的代码,即

Rogue 是一种类型安全的内部 Scala DSL,用于在 Lift Web 框架中针对 MongoDB 构建和执行查找和修改命令

我发现用 scala 编写的代码是查询以获取数据

我想将该代码转换为 mysql 查询

def getBlogScore(word: String, blog: String): Long = Keyword.where(_.word eqs word).and(_.blog eqs blog)
    .fetch.map(_.score._1)
    .reduceLeftOption(_ + _).getOrElse(0)

给我一​​些想法!

最佳答案

由于 .reduceLeft( _ + _ ) 会将所有分数加在一起,这可能就是您正在寻找的:

SELECT SUM(score)
FROM keyword
WHERE blog = 'blog'
AND word = 'word'

关于mysql - 如何将流氓查询转换为Mysql?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19680887/

相关文章:

php - 键存在于表中,但在 MySQL 中显示 Can't Drop foreign key

database - 使用 mongodb compass GUI 连接到 docker 中的 Mongodb

php - MongoDB 功能测试设置和拆卸在 4.2 中使用 WiredTiger 慢 10 倍

scala - 使用 scala.sys.process 转到 scala 中的特定路径

mysql 在我杀死进程后停止并且磁盘已满 100%

mysql - 你会如何整理这个 Mysql 逻辑

scala - 避免 shapeless 中两个类型类定义之间发生冲突的最佳方法是什么

scala - 如何简化嵌套 map 调用?

MySQL 将一个表中的值连接到另一个表的记录中

mongodb - Grails Spring安全核心3.1.2和mongodb