Re: problem with joining two tables

From: "Bill Howell" <officeware(at)worldnet(dot)att(dot)net>
To: "Giorgio A(dot)" <jh(at)libero(dot)it>, <pgsql-novice(at)postgresql(dot)org>
Subject: Re: problem with joining two tables
Date: 2001-05-21 13:50:24
Message-ID: 000e01c0e1fc$fd120a40$0218a8c0@pluto
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

You might try using DISTINCT in your query, e.g.
SELECT DISTINCT t.content, .....

Bill

----- Original Message -----
From: Giorgio A. <jh(at)libero(dot)it>
To: <pgsql-novice(at)postgresql(dot)org>
Sent: Monday, May 21, 2001 5:15 AM
Subject: [NOVICE] problem with joining two tables

> hi, i've got this problem:
> i have to manage a list of events in my city, publishing them into my web
> site; each event has a 'content' (containing infos such as title, place,
> description, etc..) and is linked to one or more dates. I I decided to
> create 2 tables, one to store the 'content' (which has a unique id), the
> other to store the dates of the events; i called the first table
'real_time'
> and the second 'real_time_ts': each two has the filed 'id_real_time' which
> is used to correlate the 'contents' with the 'dates'. Everything is going
> well, but when a content has more than one 'date' i get the same content
> repeated for the number of its dates... this is not what i want to
retrieve
> ! i want to do a SELECT which gives me only one occurance for each
content,
> even when the content has more than one date of happening ! I tried
> grouping, joining a.s.o. but i came to nothing... can anyone please help
me
> ? i really can't get out of this :-(
>
> the sql I'm using is:
>
> select t.id_realtime, t.id_real_users, t.id_places, t.id_index,
> t.content, t.shown_place, t.titol,
> s.start_date, s.end_date, s.start_time, s.end_time
> from real_time t, real_time_ts s
> where
> t.id_index = <dtml-sqlvar real_time.id_index type="nb">
> and
> t.id_real_time = s.id_real_time
> and
> ( s.start_date >= <dtml-sqlvar now type="string">
> or
> s.end_date >= <dtml-sqlvar now type="string"> )
> and
> t.prio = '1'
> order by s.start_date, s.end_date
>
>
> being "now" the current date given by ZopeTime().strftime('%Y-%m-%d')
>
> tnx to anyone who has read my e-mail and would (eventually!) help me !
>
> have a nice day,
> Giorgio A.
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 1: subscribe and unsubscribe commands go to majordomo(at)postgresql(dot)org
>

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message harrold 2001-05-22 02:01:26 toast examples.
Previous Message Nabil Sayegh 2001-05-21 10:31:16 Re: problem with joining two tables