Help fixing tricky SQL statement requested
From: Karl (ktvoelker_at_sbcglobal.net)
Date: 06/17/04
- Previous message: Daniel Kasak: "$dbh->last_insert_id() not working"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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
- Previous message: Daniel Kasak: "$dbh->last_insert_id() not working"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|
|