SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast
    Join Date
    Jan 2009
    Posts
    47
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Which faster - one row or 2 columns.

    Planning on rewriting a simple availability chart that shows the availability of a product on a weekly basis.

    Currently, it is setup as a single row, with the number of weeks as a each as column.

    ID COL1 COL 2 COL3

    Would it be better to flip it around and have two/three columns and a larger number of rows?

    ID WEEK STATUS

    The code to pull it out is pretty awful too (not mine):

    Code:
    $sqlquery = "SELECT april3, april10, april17 ... FROM avails";
    $result = mysql_query($sqlquery);
    $number = mysql_num_rows($result);
    	$i = 0;
        while ($number > $i) 
        {	
    $april3 = mysql_result($result, $i, "april3");
    $april10 = mysql_result($result, $i, "april10");
    $april17 = mysql_result($result, $i, "april17");
    ...

  2. #2
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,270
    Mentioned
    60 Post(s)
    Tagged
    3 Thread(s)
    yes
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  3. #3
    Utopia, Inc. silver trophy
    ScallioXTX's Avatar
    Join Date
    Aug 2008
    Location
    The Netherlands
    Posts
    9,081
    Mentioned
    153 Post(s)
    Tagged
    2 Thread(s)
    Quote Originally Posted by r937 View Post
    yes
    Second that.
    Makes it easier to calculate minima, maxima, averages, standard deviations, etc.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •