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.
Asked
Active
Viewed 59 times
1

Riajul Islam
- 1,425
- 15
- 19
-
`count the 'id' field of every table` means ? – Sagar Jajoriya Oct 26 '17 at 05:37
-
I want to result like as total_user = 10, total_clients = 15, total_products = 20 – Riajul Islam Oct 26 '17 at 05:41
-
1Refer to [this](https://stackoverflow.com/questions/606234/select-count-from-multiple-tables). Might give you an idea. – Jixone Oct 26 '17 at 05:42
-
Thanks @Jixone bro – Riajul Islam Jul 09 '18 at 11:02
1 Answers
1
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

Rezaul
- 26
- 3