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); Quote 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. Quote 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 Quote Link to comment https://forums.phpfreaks.com/topic/202784-which-is-more-efficient/#findComment-1062837 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.