Help fixing tricky SQL statement requested

From: Karl (ktvoelker_at_sbcglobal.net)
Date: 06/17/04

  • Next message: David: "Re: Apache, DBI, Oracle"
    Date: Thu, 17 Jun 2004 04:34:40 GMT
    
    

    I hope that there is a simple answer to this question. I'm just beginning
    to use this stuff.

    I have a couple tables, 'sectors' and 'rooms'. Each sector represents an
    area of fictional space which can contain rooms. Each sector has an
    'owner', who in this case is able to arrange the rooms with sectors under
    his or her ownership.

    The table 'sectors' has two columns that should matter here: 'id' and
    'owner'. Both are integer values. The table 'rooms' has three columns that
    matter here: 'id', 'name', and 'sector'. What I want to do is, given the
    unique number of a certain owner, come up with a list of the names and
    id's of all the rooms under that owner's control.

    Here is what I tried:

    $dbh = DBI->connect('DBI:CSV:f_dir=/it/connects/just/fine');
    $sth = $dbh->prepare('SELECT rooms.id, rooms.name FROM rooms, sectors WHERE room.sector = sector.id AND sector.owner = ?');
    $sth->execute($owner);
    while (@res = $sth->fetchrow_array) {
            print @res, '\n';
    }

    There are no errors produced by anything....just no data. I know for sure
    that I have some data in the tables matching what I want it to find. I
    think I must've just written that statement wrong...it was somewhat along
    the lines of an instinctual common-sense stab in the dark.

    Thanks for any help.
    Karl


  • Next message: David: "Re: Apache, DBI, Oracle"

    Relevant Pages

    • WTD: Maxtor Maxline II 300GB drive
      ... It must also be manufactured in Singapore. ... It doesn't matter if there are bad sectors, ... in working order. ...
      (uk.adverts.computer)
    • Re: dangerous situation with shutdown process
      ... > Nicolas Rachinsky wrote: ... >>to the sectors the OS is writing to. ... > of write barriers and a journal? ... > no matter what strategy you're using. ...
      (freebsd-stable)
    • Re: How to clone a HD in Linux?
      ... >> This doesn't matter. ... but of course also irrelevant since all hard disks really ... > do have 512B sectors. ... Optical drives have adapted the sectorsizes to match the ongoing ...
      (comp.os.linux.misc)