[MySQL] Getting data from 2 tables in 1 query
#1

This is my query:

Код:
SELECT Count(*) AS Accounts, SUM(CASE WHEN Admin > 0 THEN 1 ELSE 0 END) AS Admins, SUM(CASE WHEN VIP = 1 THEN 1 ELSE 0 END) AS VIPs FROM Accounts
^ This gets the number of rows, Admins & VIPs.

I want to merge this query with the query above

Код:
SELECT COUNT(*) As Bans FROM Bans
^ This gets the number of rows

I know there's a way, but I just can't figure out.

I want the result to be like this:

---
Accounts Admins VIPs Bans
x_________x_______x____x
---
Reply


Messages In This Thread
[MySQL] Getting data from 2 tables in 1 query - by Deathlane - 01.06.2015, 10:57
Re: [MySQL] Getting data from 2 tables in 1 query - by Vince - 01.06.2015, 11:11
Re: [MySQL] Getting data from 2 tables in 1 query - by Konstantinos - 01.06.2015, 11:14

Forum Jump:


Users browsing this thread: 1 Guest(s)