我正在使用最新版本的MySQL ==> mysql-5.6.10-winx64.zip
创建数据库,当我尝试执行这个简单的命令时,每个事情都可以'我想';
"select * from family"
Run Code Online (Sandbox Code Playgroud)
我收到了这个错误:
错误代码1064,SQL状态42000:您的SQL语法中有错误; 检查与MySQL服务器版本对应的手册,以便在第1行的'OPTION SQL_SELECT_LIMIT = DEFAULT'附近使用正确的语法
我花了很多时间寻找解决方案,但没有找到解决方案:(
我想根据Id查询用户的单行.我有以下虚拟代码
case class User(
id: Option[Int],
name: String
}
object Users extends Table[User]("user") {
def id = column[Int]("id", O.PrimaryKey, O.AutoInc)
def name = column[String]("name")
def * = id ~ name <>(User, User.unapply _)
def findById(userId: Int)(implicit session: Session): Option[User] = {
val user = this.map { e => e }.where(u => u.id === userId).take(1)
val usrList = user.list
if (usrList.isEmpty) None
else Some(usrList(0))
}
}
Run Code Online (Sandbox Code Playgroud)
在我看来,findById查询单个列是一种过度杀伤,因为Id是标准主键.有谁知道更好的方法?请注意我正在使用Play!2.1.0