The Little Guy Posted October 24, 2008 Share Posted October 24, 2008 How can I get the total number of rows from one table and the total number of rows from another table from my database using one query? Quote Link to comment https://forums.phpfreaks.com/topic/130016-solved-count-of-two-tables/ Share on other sites More sharing options...
DarkWater Posted October 24, 2008 Share Posted October 24, 2008 SELECT COUNT(*) AS total1 FROM table_1 UNION SELECT COUNT(*) AS total2 FROM table_2; Quote Link to comment https://forums.phpfreaks.com/topic/130016-solved-count-of-two-tables/#findComment-674084 Share on other sites More sharing options...
The Little Guy Posted October 24, 2008 Author Share Posted October 24, 2008 I would like to do this without a union, is it possible? Quote Link to comment https://forums.phpfreaks.com/topic/130016-solved-count-of-two-tables/#findComment-674085 Share on other sites More sharing options...
Barand Posted October 24, 2008 Share Posted October 24, 2008 SELECT ( SELECT COUNT(*) FROM table1 ) as t1, ( SELECT COUNT(*) FROM table2 ) as t2 Quote Link to comment https://forums.phpfreaks.com/topic/130016-solved-count-of-two-tables/#findComment-674089 Share on other sites More sharing options...
The Little Guy Posted October 24, 2008 Author Share Posted October 24, 2008 Yey! Finally! Thank you! Quote Link to comment https://forums.phpfreaks.com/topic/130016-solved-count-of-two-tables/#findComment-674092 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.