www.webdeveloper.com
Results 1 to 4 of 4

Thread: mysql select

  1. #1
    Join Date
    May 2011
    Posts
    58

    Question mysql select

    Hello i want to select from database looks like this (id, nickname)
    id is unique and nickname can be input many times, i select rows from base something like this
    PHP Code:
    select from my_table order by id desc limit 0,20 
    start of limit changing by the page.
    But now i want to change row select. I want to select 20 rows but with condition that withdraw only 4 rows for one nick per page (per 20 rows).
    I don't understand how can i make it.

  2. #2
    Join Date
    Oct 2011
    Location
    United States
    Posts
    2
    Mmm, do you mind re phrasing your post? I don't understand what you need done.

  3. #3
    Join Date
    May 2011
    Posts
    58
    i have a column "nickname" and i need to make a query which will withdraw 20 rows, in this query i need to withdraw only 4 rows per one nickname(or lower than 4 rows by 1 nickname)

  4. #4
    Join Date
    Jan 2006
    Location
    MN
    Posts
    440
    A loop might do it.
    PHP Code:
    $sql"SELECT DISTINCT (nickname) FROM mytable ORDERBY nickname ASC LIMIT 20";

    $result mysql_query ($sql)
    while 
    $somerowmysql_fetch_assoc($result){
         
    $nick $somerow['nickname'];

    $sql2 "SELECT id,nickname FROM mytable WHERE nickname = '" $nick"' ORDER BY id ASC LIMIT 4;
    $result2 = mysql_query($sql2);
    while 
    $myrow = mysql_fetch_assoc($result2){

    echo 
    $myrow['id'] . " " . $myrow['nickname'] . "<br>";
    }



Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

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



Recent Articles