在我的数据库中获得顶级克隆人? [英] Getting top cloners in my Database?

查看:59
本文介绍了在我的数据库中获得顶级克隆人?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否有人至少可以帮助我找到从哪里开始.我知道这是一个很大的问题,但我已经寻找了一段时间,但找不到与如何处理这两列有关的任何内容.

I wondered if anyone could at least help me find where to start with this. I understand its a large question but I have looked for a while and I can't find anything related to how to do with this two columns.

我有一个名为用户"的表,我想选择克隆次数最多的前20名帐户.当我说克隆帐户时,我的意思是我想显示一个用户名的列表,该用户名中具有相同IP或计算机ID的帐户最多.

I have a table called 'users', I want to select the top 20 with the most cloned accounts. When I say cloned accounts, I mean that I want to show a list of user's usernames who have the most accounts with the same IP or Machine ID.

IP列称为ip_last,计算机列称为machine_id.

The IP column is called ip_last and the machine column is called machine_id.

我将如何获得克隆次数最多的前20名帐户?我只想显示用户名,通过IP克隆多少个帐户以及通过Machine克隆多少个帐户.

How would I go about getting the top 20 with the most cloned accounts? All I want to display is the username, how many accounts cloned by IP, and how many accounts cloned by Machine.

Id接受知道如何在MySQL中执行此操作,但是如果有人可以帮助我使其与Laravel一起使用,那也将大有帮助.

Id accept knowing how to do this in MySQL, but if someone could help me get it working with Laravel then that would also help a lot.

推荐答案

可以尝试吗?

$result = DB::table('users')
             ->select('ip_last', DB::raw('count(*) as total'))
             ->groupBy('ip_last')
             ->take(20);

machine_id也是一样,对于两者,您都可以尝试->groupBy('ip_last','machine_id').

The same is for machine_id, and for both you can try ->groupBy('ip_last','machine_id').

这篇关于在我的数据库中获得顶级克隆人?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆