cant select all records

Discussion in 'MySQL' started by ignas2526, Jun 1, 2009.

  1. #1
    Hello,
    I have a problem: for unknown reason i can't select all records from table, it shows me 1 of 3 records.

    table1 structure:
      `some_value1` varchar(20) NOT NULL,
      `some_value2` varchar(100) NOT NULL,
      `name` varchar(5) NOT NULL,
      UNIQUE KEY `name` (`name`)
    Code (markup):
    Content:
    INSERT INTO `table1` (`some_value1`, `some_value2`, `name`) VALUES
    ('something1', 'another value1', 'rec1'),
    ('something2', 'another value2', 'rec2'),
    ('something3', 'another value3', 'rec3');
    Code (markup):
    Query:
    SELECT name FROM table1
    Code (markup):
    Result:
    array('name'=>'rec2')
    Code (markup):
    Expected result:
    array('name'=>array('rec1','rec2','rec3'))
    Code (markup):
    SQL version: 5.1.33
    PHP Version: 5.2.9

    I tried to clear browser cache, restart MySQL and Apache server, still nothing.
    Any ideas what i doing wrong?
    Thanks.
     
    ignas2526, Jun 1, 2009 IP
  2. Ralle

    Ralle Active Member

    Messages:
    35
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    91
    #2
    Are you using PHP to fetch the data?
    Then you have to make a loop, like this:
    
    $query = mysql_query("SELECT name FROM table1");
    
    while($row = mysql_fetch_assoc($query)) {
        print_r($row);
    }
    PHP:
     
    Ralle, Jun 1, 2009 IP