Link to home
Start Free TrialLog in
Avatar of Super26
Super26

asked on

Getting the count of multiple tables with one SQL statement

Is there any way we can get the total count of multiple tables with one sql statement? Something like this:

Select count(Video_ID) As VideoCount, count(Customer_ID) As CustomerCount from Video, Customer

Obviously this doesn't work, I was wondering if there was any correct way of doing this. I would appreciate any help. Thanks.
Avatar of TextReport
TextReport
Flag of United Kingdom of Great Britain and Northern Ireland image

You can use a UNION Query

Select 'VideoCount', Count(*) As Quantity FROM VideoCount
UNION
Select 'CustCount', Count(*) As Quantity FROM Customer

Cheers, Andrew
ASKER CERTIFIED SOLUTION
Avatar of TextReport
TextReport
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Super26
Super26

ASKER

Thanks so much TextReport.  I used the second example you gave me.  You've saved me hours worth of work, once again, thanks!