Skip to main content

All Questions

Tagged with
Filter by
Sorted by
Tagged with
0 votes
1 answer
951 views

Laravel withCount of all comments and child comments

I am using Laravel 8 and the withCount attribute to get the amount of all comments which are published on my products model. Those comments have child comments as well. Now I would like to get the ...
Jan's user avatar
  • 592
1 vote
1 answer
134 views

mysql query to count customers with certain number of products

I have a customer table containing these two fields (actually way more but this is simplified): customerAcct, product I need to count the number of customers that have a certain number of each ...
Xi Vix's user avatar
  • 1,361
0 votes
2 answers
109 views

MYSQL select number of elements FOREACH element in another table

I have two databases, each containing one table, users.user_groups and logins.logins. The first one contains a list of users and their corresponding groups as follows :- mysql>select * from users....
user3765349's user avatar
1 vote
1 answer
142 views

Nested count in one Query

I need to count a the amount of unread messages per type of a messages table. Table: Messages Fields: Id Message Type Unread 1 xxxxx 0 0 2 xxxxx 1 0 3 xxxxx 1 0 4 xxxxx 1 ...
Lucas's user avatar
  • 384
0 votes
2 answers
1k views

SQL nested count

first: yes i'm a sql noob and i really need some help: SELECT COUNT(id), SUM(rating), COUNT(rating) FROM comments WHERE phone='$phone';" this needs to be something like this: SELECT COUNT(id), SUM(...
Dublay's user avatar
  • 65
1 vote
2 answers
97 views

Pulling info from the same table in different orders and quantities using MySQL

First time post. As an example, say I have a table with 12 entries; +--------+------------+ | name | date | +--------+------------+ | P1 | 2011-12-01 | | P2 | 2012-01-01 | | P3 | ...
Bilbo's user avatar
  • 355