ale1981 Posted July 19, 2007 Share Posted July 19, 2007 I have always wondered if there is a way of doing a quicker select statement than the one below; $userID = $_GET['userID']; $result = mysql_query("SELECT name FROM users WHERE userID = $userID"); $row = mysql_fetch_row($result); echo $row[0]; Can this query be shortened for simple queries like this one where I just want to retrieve a single field from one row? Quote Link to comment Share on other sites More sharing options...
metrostars Posted July 19, 2007 Share Posted July 19, 2007 That is simple. You can't get it any more simple than that. unless you want to put LIMIT 0, 1 on the end, although it isn't necessary if userid is a primary field anyways. Quote Link to comment Share on other sites More sharing options...
ale1981 Posted July 19, 2007 Author Share Posted July 19, 2007 Yes I know it is simple, its just i have always wondered if there is a simpler way! Thanks for your reply. Quote Link to comment Share on other sites More sharing options...
ale1981 Posted July 19, 2007 Author Share Posted July 19, 2007 I have actually found an easier way (well for me anyway!); $userID = $_GET['userID']; $result = mysql_query("SELECT userName FROM users WHERE userID = $userID"); $userName = mysql_result($result, 0); echo $userName; ... not quite the same!! Quote Link to comment 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.