在数据库中搜索游戏作品

考克斯

你好,我有一个小问题,我在playframework中创建了项目,我必须在数据库中找到所有姓,我已经通过使用function来做到这一点

List<Classname> surnames = classname.find.all()

但是当我请求http时,我得到了所有的用户名,姓氏,邮件,ID。

我当时正在考虑使用

List<Account> users = Account.find.where().like("surname","surname").findList();

但是,当我从http获得带有此功能的请求时,我只会得到[]

有人可以帮我吗?我会很感激

我已经按照您说的做了,但是在收到请求后,这不仅给我提供了我现在喜欢的姓氏,而且

    List<Account> surnam = Account.find.where().orderBy("surname asc").findList();
    Vector<String> surnames = new Vector<>();
                for(Account a: surnam)
                {
                   surnames.add(a.getSurname());
                }

现在,这仅显示我的姓氏,但这是使它更漂亮的方法,我的意思是不使用每个循环?

比西奥
List<Account> accounts = Account.find.select("surname").findList();

将创建一个查询(伪代码)

SELECT id, surname FROM account

请注意,Ebean始终将id字段添加到查询中以进行映射

如果您想按某个字段进行搜索,即查找所有约翰·确实使用,请使用:

List<Account> accounts = Account.find.select("surname").where().like("surname", "%Doe%").findList();

这将创建查询:

SELECT id, surname FROM account WHERE surname LIKE '%Doe%'

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章