Jump to content

bubblegum.anarchy

Members
  • Posts

    526
  • Joined

  • Last visited

    Never

Posts posted by bubblegum.anarchy

  1. Lets say that you have a table with two columns: x and y

     

    You pull a query:

     

    SELECT x, y FROM table GROUP BY x

     

    This will only return one record for each value of x, nut my question is which record does it use for the value of y? And can you select which record is used to return y using an ordering rule?

    The first record for each unique `x` group is returned if no group by function is applied to `y`, but apparently there is no guarantee of this happening.

  2. Now the problem is this, i had to move my site to a new server, and the new server runs php in safe mode, so i'm able to run the mysqldump but i'm not able to run the mysql < dumpfile because the "<" is not permited... dont know why...

    I thought `<` is a linux piping command, nothing to do with php - contact your server admin.

  3. are you sure you are not connecting as an anonymous user that has no permissions?

     

    create a basic connection file on the server for testing like this, straight out of the php manual, to verify the connection settings:

    <?php
    // Connecting, selecting database
    $link = mysql_connect('mysql_host', 'mysql_user', 'mysql_password')
       or die('Could not connect: ' . mysql_error());
    echo 'Connected successfully';
    mysql_select_db('my_database') or die('Could not select database');
    
    // Performing SQL query
    $query = 'SELECT * FROM my_table';
    $result = mysql_query($query) or die('Query failed: ' . mysql_error());
    
    // Printing results in HTML
    echo "<table>\n";
    while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) {
       echo "\t<tr>\n";
       foreach ($line as $col_value) {
           echo "\t\t<td>$col_value</td>\n";
       }
       echo "\t</tr>\n";
    }
    echo "</table>\n";
    
    // Free resultset
    mysql_free_result($result);
    
    // Closing connection
    mysql_close($link);
    ?>
    

  4. I suppose extract(year from birthdate) would be faster than round(datediff(CURRENT_DATE, birthdate) / 365) and if the following is correct than extracting the date is substantially quicker:

    DROP TABLE IF EXISTS birthdate;
    
    CREATE TABLE birthdate (
    id int(11) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
    birthdate DATE NOT NULL 
    )TYPE=MYISAM;
    
    INSERT INTO birthdate SET birthdate = '1974-12-03';
    INSERT INTO birthdate (birthdate) SELECT adddate(birthdate, 1) FROM birthdate; # repeated a number of times
    
    SELECT count(*) FROM birthdate; # records created 2097152
    
    SELECT count(round(datediff(CURRENT_DATE, birthdate) / 365)) AS test FROM birthdate; # average around 922 ms
    
    SELECT count(extract(year from birthdate)) AS test FROM birthdate; # average around 328 ms
    

  5. notepad was commenting on the server setup

     

    I work from home with WIMP (windows, IIS, mysql, php) and upload to a work server that is LAMP (linux, apache, mysql, php) both old versions of php and mysql so I am no help.. a google search on windows IIS php mysql install instructions should provide plenty of helpful information.

     

    Just make sure what ever versions of php and mysql you install on your local machine for testing is the same as what is available on the production server!!

  6. have you tried removing PRIMARY or adding the word KEY

     

    and consider changing

    userSignupDate datetime NOT NULL default="now()",

    to

    userSignupDate timestamp NOT NULL default timestamp,

     

    remove all the = signs and define the primary key either in the column definition or the statement footer

     

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