Results 1 to 2 of 2

Thread: I'm stumped...

  1. #1
    Join Date
    Jul 2007
    Location
    England
    Posts
    41
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Question I'm stumped...

    I have the following code to work out the difference between two fields on successive rows, and this works fine.

    PHP Code:
    $query6="
    SELECT t1.id AS id1, t2.id AS id2,
    t1.overallr AS overallr1, t2.overallr AS overallr2,
    t2.overallr-t1.overallr AS dist
    FROM 
    {$table} AS t1, {$table} AS t2
    WHERE t1.id+1 = t2.id
    ORDER BY t1.id;
    "

    On another page I'm using the following code to select every 24th row in the table.

    PHP Code:
    $query7="SELECT * FROM {$table} WHERE id = '1' or id % 24 = 0"
    But for some reason I can't combine the two concepts. I want to "execute" the first bit of code on every 24th row, instead of all of them.

    Thank you in advance- I hope you can help.

  2. #2
    Join Date
    May 2007
    Location
    Boston,ma
    Posts
    2,127
    Thanks
    173
    Thanked 207 Times in 205 Posts

    Default

    $query7="SELECT ID FROM {$table} WHERE id = '1' or id % 24 = 0";

    $fetchedresults

    $query6="SELECT t1.id AS id1, t2.id AS id2, t1.overallr AS overallr1, t2.overallr AS overallr2, t2.overallr-t1.overallr AS dist FROM {$table} AS t1, {$table} AS t2 WHERE t1.id+1 = t2.id and t1 = $fetchedresults or t2 = $fetchedresults ORDER BY t1.id; ";


    Maybe something like that?

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
  •