pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: QdlatY <qdlaty@wielun.dhs.org>
To: pgsql-sql@postgresql.org
Subject: difficult query (for me)
Date: Sat, 29 Dec 2001 16:20:35 +0100
Message-ID: <1132751000.20011229162035@wielun.dhs.org> (raw)

Hello

I will try to explain my problem as clearly as i can.

So, I have tree tables
Named:

Tables
Threads
Posts

It is typicall structure of discussion phorum.
Now, Tables has a column ID (unique random index)
Threads has a columns ID (index) and TableID (index of one row of tables 
table)
Posts has attribute ThreadId and CreateTime

(i only wrote important columns to this query)

Now, I have Tables row with ID = 10
And then i want to have list of all Threads (belongs to Table with id = 10, 
so WHERE Threads.TableId = 10) sorted by CreateTime of newest Posts row 
belong to every thread.

F.E.
Table.iD = 10

Thread
ID TableID
1  10
2  10
3  11

Posts
ThreadId  CreateTime (i will use nubers only to explain)
1         10
1         20
1         25
2         43
3         02


So i want to have result from Table ID = 10:
Threads
ID
2    (because  CreateTime of Posts from 2 Thread is highest)
1    (and so on...)

(Thread 3 not belongs to Table.ID = 10)

Of course result can contains adequate Posts columns but don't must to...

I hope you will able to help me, i think it's not difficult but i'm a 
little newbie, so, i gave up on this :PPP

Best regards
QdlatY




view thread (7+ messages)  latest in thread

Message-ID: <1132751000.20011229162035@wielun.dhs.org>
Permalink:  ../1132751000.20011229162035@wielun.dhs.org/
Also on:    postgresql.org/message-id/1132751000.20011229162035@wielun.dhs.org

 · 

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: qdlaty@wielun.dhs.org
  Subject: Re: difficult query (for me)
  In-Reply-To: <1132751000.20011229162035@wielun.dhs.org>

* 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