phorcon3 Posted August 18, 2008 Share Posted August 18, 2008 $a=mysql_query("(SELECT Count(id) AS Count FROM `t1` WHERE `this` = '$_GET[text]') UNION (SELECT Count(id) AS Count FROM `t2` WHERE `this` = '$_GET[text]')"); $b=mysql_fetch_assoc($a); echo $b['Count']; that obviously only gives back the result from t1...but how can i make sure it adds both counts ..from t1 and t2? Link to comment https://forums.phpfreaks.com/topic/120167-solved-mysql-union-count/ Share on other sites More sharing options...
Mchl Posted August 18, 2008 Share Posted August 18, 2008 SELECT ((SELECT Count(id) AS Count FROM `t1` WHERE `this` = '$_GET[text]') + (SELECT Count(id) AS Count FROM `t2` WHERE `this` = '$_GET[text]')) AS total Link to comment https://forums.phpfreaks.com/topic/120167-solved-mysql-union-count/#findComment-619093 Share on other sites More sharing options...
phorcon3 Posted August 18, 2008 Author Share Posted August 18, 2008 thanks!! Link to comment https://forums.phpfreaks.com/topic/120167-solved-mysql-union-count/#findComment-619167 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.