Jump to content

Recommended Posts

Hey

 

This maybe a stupid question, but everyone i look people seem to only SELECT * FROM ... even in tutorials...

 

and therefore,thats what iv been doing for the last year... but our site is rather big and im thinking the little * is pulling waaay to much info than it needs, so i went through and converted * to specific columns that i need..its going to be a few days till i can see if this made an impact..

 

Server wise, will switching from * to specific columns needed make a difference? as id imagine with just selecting specific colums, it might take a little more processing to be specific, rather than * just pulls the whole lot..?

Link to comment
https://forums.phpfreaks.com/topic/150952-select-or-select-this-this-this-this/
Share on other sites

thats what i was hoping for :)

 

so selecting certain colums do i still do this to get the content?

 

SELECT usernick, games_won, games_payed, tname FROM table

while($row = mysql_fetch_array($result)){

  $_SESSION['nickname'] = $row['usernick'];
  $_SESSION['played'] = $row['games_played'];
  $_SESSION['won'] = $row['games_won'];
  $_SESSION['tname'] = $row['tname'];

}

 

or would the columns already be in an array?

 

also, if theres only one result set returned, im guessing i dont need the while statement?

Hi

 

As above. Also if you use SELECT * and the layout of the database changes then you can have unforseen effects (especially if you refer to column numbers rather than names). Also if you have a table join and a column is added to one table that has the same name as a column in the other table then again you can have unexpected abends in the future.

 

All the best

 

Keith

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.