EchoFool Posted May 25, 2010 Share Posted May 25, 2010 Hey, Just wondering which is more efficient in these 2 scripts as i love being as efficient as possible: SELECT Count(ID) AS TotalID FROM table WHERE ID = 2 //display echo $row['TotalID']; OR $QUERY = SELECT ID FROM table WHERE ID = 2 //display echo mysql_num_rows($QUERY); Link to comment https://forums.phpfreaks.com/topic/202784-which-is-more-efficient/ Share on other sites More sharing options...
premiso Posted May 25, 2010 Share Posted May 25, 2010 Count would be more efficient, as doing a query will pull all ID's from the database, where count does what it says and just counts the data. Link to comment https://forums.phpfreaks.com/topic/202784-which-is-more-efficient/#findComment-1062834 Share on other sites More sharing options...
EchoFool Posted May 25, 2010 Author Share Posted May 25, 2010 Okay thanks Link to comment https://forums.phpfreaks.com/topic/202784-which-is-more-efficient/#findComment-1062837 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.