Hi, I need to create a sql query that will return the sum of the total number of records in the t1 and t2 tables. Any ideas how to do it?

Thnx in advance

Re: Num rows of two tables with one query 80 80
select count(*) from (select 1 from t1 UNION ALL select 1 from t2) as both_tables;
Re: Num rows of two tables with one query 80 80

Thank you very much! And can you explain what "1" does mean in your select?

Re: Num rows of two tables with one query 80 80

It provides the constant 1 for each row that matches the where clause. There is no where clause, so it gives a 1 for each row in the table.

Re: Num rows of two tables with one query 80 80

Thanks!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.19 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.