COUNT on multiple tables

1

I have two tables in my system, and I need to do a two-column count on the tables. I currently do through a VIEW as follows:

CREATE VIEW totais AS
(SELECT (SELECT COUNT(publications.id) FROM publications) AS total1,
(SELECT COUNT(deejays.id) FROM deejays) AS total2)

I need to do this through a SELECT but I can not do it.

    
asked by anonymous 01.09.2017 / 17:15

2 answers

3

You can do this:

SELECT
  (SELECT COUNT(publications.id) FROM publications) AS total1,
  (SELECT COUNT(deejays.id) FROM deejays) AS total2)
    
01.09.2017 / 17:44
0

One way that could be done is also the following:

SELECT COUNT(publications.id) as total1, 
COUNT(deejays.id) as total2 
from publications, deejays
    
01.09.2017 / 19:40