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

Recommended Answers

All 4 Replies

select count(*) from (select 1 from t1 UNION ALL select 1 from t2) as both_tables;

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

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.

Thanks!

Be a part of the DaniWeb community

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