pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Bruce Young <hbrucey@yahoo.com>
To: pgsql-sql@postgresql.org
Subject: displaying correct name
Date: Thu, 13 Mar 2003 19:11:28 -0800 (PST)
Message-ID: <20030314031128.15799.qmail@web10411.mail.yahoo.com> (raw)

Hi list!
I have two tables. One is contains User info, the other requesting info.
ownerid and buyerid are userid in the usertable.


         Table "users"
  Column   |            Type             |   
-----------+-----------------------------+
 userid    | integer                     | serial
 username  | character varying(25)       |
 password  | character varying(32)       |


          Table "item"
     Column     |          Type          | 
----------------+------------------------+
 itemid         | integer                | serial
 userid         | integer                |
 title          | character varying(100) |


         Table "requests"

   Column   |            Type             |
------------+-----------------------------+
 requestid  | integer                     | serial
 ownerid    | integer                     |
 buyerid    | integer                     |
 itemid     | integer                     |
 

what i want to do is select from "requests" where ownerid=<integer>.
the result should contain the users.username of requests.buyerid and the
item.title of requests.itemid.
my problem is... i am getting the username of requests.ownerid instead from my
query.
here is my query:

select u.username, i.title from test.requests r, test.users u, test.items i
  where r.ownerid=u.userid and r.itemid=i.itemid
  and r.ownerid = (select userid from test.users where userid=1);
 
thanks.
any help appreciated.

  - bruce


__________________________________________________
Do you Yahoo!?
Yahoo! Web Hosting - establish your business online
http://webhosting.yahoo.com



view thread (2+ messages)  latest in thread

Message-ID: <20030314031128.15799.qmail@web10411.mail.yahoo.com>
Permalink:  ../20030314031128.15799.qmail@web10411.mail.yahoo.com/
Also on:    postgresql.org/message-id/20030314031128.15799.qmail@web10411.mail.yahoo.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: hbrucey@yahoo.com
  Subject: Re: displaying correct name
  In-Reply-To: <20030314031128.15799.qmail@web10411.mail.yahoo.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox