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? 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; 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? 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 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! 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
Archived
This topic is now archived and is closed to further replies.