One Quickie


Selecting a random row from a table (Postgresql->General)
use the random() function.
    select stuff.src, stuff.width, stuff.height from
        (select src, width, height,
                random()
           from bw_eyes
          order by 4) stuff
    limit 1
This selects a random row from bw_eyes and returns the interesting data from it. This query is used on the quickies pages to randomly select an image of eyes staring back.



borkware home | products | miniblog | rants | quickies | cocoaheads
Advanced Mac OS X Programming book

webmonster@borkware.com