Jump to content

Select * or select this, this this, this


TEENFRONT

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.