pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feeddisplaying correct name
2+ messages / 2 participants
[nested] [flat]
* displaying correct name
@ 2003-03-14 03:11 Bruce Young <hbrucey@yahoo.com>
0 siblings, 1 reply; 2+ messages in thread
From: Bruce Young @ 2003-03-14 03:11 UTC (permalink / raw)
To: pgsql-sql
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
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: displaying correct name
@ 2003-03-14 07:56 Tomasz Myrta <jasiek@klaster.net>
parent: Bruce Young <hbrucey@yahoo.com>
0 siblings, 0 replies; 2+ messages in thread
From: Tomasz Myrta @ 2003-03-14 07:56 UTC (permalink / raw)
To: Bruce Young <hbrucey@yahoo.com>; +Cc: pgsql-sql
Bruce Young wrote:
<cut>
> 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
???
As you answered yourself in description above, change
r.ownerid=u.userid into r.buyerid=u.userid
Regards,
Tomasz Myrta
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2003-03-14 07:56 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2003-03-14 03:11 displaying correct name Bruce Young <hbrucey@yahoo.com>
2003-03-14 07:56 ` Tomasz Myrta <jasiek@klaster.net>
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