pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedPlz, what is the most "correct" method
2+ messages / 2 participants
[nested] [flat]
* Plz, what is the most "correct" method
@ 2003-09-10 16:01 PipHans <piphans@hotmail.co>
0 siblings, 1 reply; 2+ messages in thread
From: PipHans @ 2003-09-10 16:01 UTC (permalink / raw)
To: pgsql-sql
Hi,
Given 2 tables:
Table1:
id Auto,int,PrimKey
table2id int
txt nvarchar50
Table2:
id Auto,int,PrimKey
order int
The scenario: Table2.order defines how the table1.txt is should be ordered.
Table1.table2id contains the id of the order. This cannot be changed
How do I select all Table1.txt values but ordered by their corresponding
values of the table2.order field?
--
Thx,
PipHans
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.516 / Virus Database: 313 - Release Date: 01-09-2003
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: Plz, what is the most "correct" method
@ 2003-09-15 08:33 Richard Huxton <dev@archonet.com>
parent: PipHans <piphans@hotmail.co>
0 siblings, 0 replies; 2+ messages in thread
From: Richard Huxton @ 2003-09-15 08:33 UTC (permalink / raw)
To: PipHans <piphans@hotmail.co>; pgsql-sql
On Wednesday 10 September 2003 17:01, PipHans wrote:
> Table1:
> id Auto,int,PrimKey
> table2id int
> txt nvarchar50
>
> Table2:
> id Auto,int,PrimKey
> order int
>
> The scenario: Table2.order defines how the table1.txt is should be ordered.
> Table1.table2id contains the id of the order. This cannot be changed
>
> How do I select all Table1.txt values but ordered by their corresponding
> values of the table2.order field?
Sorry for the delay here - are you subscribed to the list? If not that can
slow things down (it only showed Monday, after you posted Wednesday).
All you need to do is join the two tables and order by the required field
SELECT t1.id, t1.txt FROM table1 as t1, table2 as t2
WHERE t1.table2id=t2.id
ORDER BY t2.order
--
Richard Huxton
Archonet Ltd
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2003-09-15 08:33 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2003-09-10 16:01 Plz, what is the most "correct" method PipHans <piphans@hotmail.co>
2003-09-15 08:33 ` Richard Huxton <dev@archonet.com>
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