[an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive]
 
[an error occurred while processing this directive] [an error occurred while processing this directive]
Skåne Sjælland Linux User Group - http://www.sslug.dk Home   Subscribe   Mail Archive   Forum   Calendar   Search
MhonArc Date: [Date Prev] [Date Index] [Date Next]   Thread: [Date Prev] [Thread Index] [Date Next]   MhonArc
 

Re: [PROGRAMMERING] sql select fra to tabeller



> Hej,
>
> Hvordan er det lige man laver et (postgresql) select fra to tabeller og
> får det samlet i en?
>
> Jeg vil gerne have:
>
>  SELECT dato FROM tabel_a WHERE dato > date('now'); samlet med
>  SELECT dato FROM tabel_b WHERE dato > date('now');

Hmm, det ligner en designfejl hvis du har brug for det og ikke kan det.

> Så jeg kan have et "ORDER BY dato LIMIT 3" på den samlede tabel.

Jeg kan ikke se andet end at du skal kopiere til en temporær tabel
SELECT dato INTO TEMP TABLE mytbl FROM tabel_a LIMIT 3;
SELECT dato INTO TEMP TABLE mytbl FROM tabel_b LIMIT 3;
SELECT * FROM mytbl LIMIT 3;

http://www.postgresql.org/docs/7.4/interactive/sql-selectinto.html

> Et andet spørgsmål, i samme stil.

Det er nu ikke i samme stil jvf. dit subject, da der kun er een tabel.

> Hvordan får man:
>
>  SELECT fornavn, efternavn FROM tabel;
>
> samlet til bare "navn" og ikke to kolonner?

SELECT fornavn || ' ' || efternavn FROM tabel;

http://www.postgresql.org/docs/8.1/static/functions-string.html
Se "string concatenation"

/hans



 
Home   Subscribe   Mail Archive   Index   Calendar   Search

 
 
Questions about the web-pages to <www_admin>. Last modified 2006-06-01, 02:01 CEST [an error occurred while processing this directive]
This page is maintained by [an error occurred while processing this directive]MHonArc [an error occurred while processing this directive] # [an error occurred while processing this directive] *