Monkuar Posted March 4, 2012 Share Posted March 4, 2012 If it faster to use call all the table using *, or calling each individual row/field? Which is betteR: $result = $db->query('SELECT u.*, g.*, o.logged FROM '.$db->prefix.'users AS u INNER JOIN '.$db->prefix.'groups AS g ON u.group_id=g.g_id LEFT JOIN '.$db->prefix.'online AS o ON o.user_id=u.id WHERE u.id='.intval($cookie['user_id'])) or error('Unable to fetch user information', __FILE__, __LINE__, $db->error()); $pun_user = $db->fetch_assoc($result); OR $result = $db->query('SELECT u.id,u.username,u.color,u.star/*ETCETC*ETC*ETC/blablahj....., g.*, o.logged FROM '.$db->prefix.'users AS u INNER JOIN '.$db->prefix.'groups AS g ON u.group_id=g.g_id LEFT JOIN '.$db->prefix.'online AS o ON o.user_id=u.id WHERE u.id='.intval($cookie['user_id'])) or error('Unable to fetch user information', __FILE__, __LINE__, $db->error()); $pun_user = $db->fetch_assoc($result); Quote Link to comment https://forums.phpfreaks.com/topic/258222-php-mysql-question/ Share on other sites More sharing options...
blacknight Posted March 4, 2012 Share Posted March 4, 2012 if your using all the firnds in a table yes if not .. then no if i only need 5 out of say 15 foelds i state eacj if i need them all i use * Quote Link to comment https://forums.phpfreaks.com/topic/258222-php-mysql-question/#findComment-1323675 Share on other sites More sharing options...
trq Posted March 4, 2012 Share Posted March 4, 2012 It is always best to explicitly tell mysql what fields you want. Quote Link to comment https://forums.phpfreaks.com/topic/258222-php-mysql-question/#findComment-1323696 Share on other sites More sharing options...
fenway Posted March 5, 2012 Share Posted March 5, 2012 It is always best to explicitly tell mysql what fields you want. Unless you want ALL of them, use * -- if you want something lazy, then write a function that will deal with the column definitions fory ou. Quote Link to comment https://forums.phpfreaks.com/topic/258222-php-mysql-question/#findComment-1323988 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.