sql >> データベース >  >> RDS >> Mysql

PHP/MySQLクエリの結果

    このようなものを試してください

    // note we need to order by maincategory for this to work
    //
    $query = "SELECT DISTINCT a.categoryname AS maincategory, b.categoryname AS   
    smallcategory FROM wscategories a, wssubcategories b WHERE a.SECTION = 'girls' AND  
    b.parentcategory = a.id
    ORDER BY maincategory ASC,
    smallcategory ASC
    ";
          $result = mysql_query($query) or die(mysql_error());
    
    
          // keep track of previous maincategory
          $previous_maincategory = NULL;
    
          while ($row = mysql_fetch_assoc($result))
          {
    
            // if maincategory has changed from previouscategory then display it
            if ($previous_maincategory != $row['maincategory']) {
                echo $row['maincategory'];
            }
    
            echo "<br/>";
            echo $row['smallcategory'];
            echo "<br/>";
    
            // record what the previous category was
            $previous_maincategory = $row['maincategory'];
          }
    


    1. 同じデータの組み合わせを持つ行に同じIDを割り当てます

    2. MySQLのエラー1005(外部キー構文から?)

    3. GrailsアプリのMySqlで壊れたパイプの例外

    4. 開発者向けQ&Aフォーラムに参加する