Riajul Islam
Riajul Islam

Reputation: 1483

Laravel mysql How can count field of multiple table in same query

I have three mysql table named users,'clients' and 'products'. I want to count the 'id' field of every table in same query. Is it possible? please help me. Thanks in advance.

Upvotes: 1

Views: 63

Answers (1)

Rezaul
Rezaul

Reputation: 26

Please this statement

SELECT u.total_users, c.total_clients, p.total_products (
 SELECT COUNT(id) as total_users FROM users
) as u,
(
  SELECT COUNT(id) as total_clients FROM clients
) as c,
(
   SELECT COUNT(id) as total_products FROM products
) as p

Upvotes: 1

Related Questions