当前位置:网站首页>Laravel 实现 groupBy 查询分组数量
Laravel 实现 groupBy 查询分组数量
2022-06-26 06:07:00 【兄弟你的假发】
如何用laravel来实现以下sql呢?
select `book_name`, count(*) as num from `clock_books` group by `book_name`
可使用laravel的原始表达式DB::raw()来操作:
$books = DB::table('books')
->select('book_name', DB::raw('count(*) as num'))
->groupBy('book_name')
->get();
||
$users = DB::table('books')
->select(DB::raw('count(*) as num, book_name'))
->groupBy('book_name')
->get();
边栏推荐
- PyTorch使用多GPU并行训练及其原理和注意事项
- MySQL-07
- Matching environment of ES6
- Redis multithreading and ACL
- Easy to understand from the IDE, and then talk about the applet IDE
- The interviewer with ByteDance threw me an interview question and said that if I could answer it, other companies would have an 80% chance of passing the technical level
- 04. basic data type - list, tuple
- 数据可视化实战:数据可视化
- canal部署、原理和使用介绍
- Combined mode, transparent mode and secure mode
猜你喜欢

String class learning

Transaction and message semantics

Logstash - logstash pushes data to redis

Logstash - logstash sends an alarm email to email

Mysql-10 (key)

Pychart cannot run designer Exe (this application failed to start because no Qt platform plugin could be I appears)

Cython入门

Transformer中的Self-Attention以及Multi-Head Self-Attention(MSA)

Library management system

Spark source code analysis (I): RDD collection data - partition data allocation
随机推荐
【Spark】Spark SQL 字段血缘如何实现
Five solutions across domains
Hot! 11 popular open source Devops tools in 2021!
Bubble sort
Prototype mode, Baa Baa
"= =" difference from "equals"
5 minutes to learn regular expressions
MobileNets: Efficient Convolutional Neural Networks for Mobile Vision Applications
Spark source code analysis (I): RDD collection data - partition data allocation
MySQL 索引底层原理
NPM private server problem of peanut shell intranet penetration mapping
Comparison between Prometheus and ZABBIX
Underlying principle of MySQL index
Thread status and stop
C generic speed
Gram matrix
Tencent's 2022 school recruitment of large factories started with salary, and the general contracting of cabbage is close to 40W!
消息队列-功能、性能、运维对比
numpy.frombuffer()
Func < T, tresult > Commission - learning record