Getting the count of multiple tables with one SQL statement

Super26
Super26 used Ask the Experts™
on
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.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
You can use a UNION Query

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

Cheers, Andrew
You can also do it like

SELECT a.qty As Computer, b.qty As System
FROM (Select Count(*) As qty FROM tblComputers) a
    ,(Select Count(*) As qty FROM tblSystems) b

Cheers, Andrew

Author

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

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial