pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedtrouble with query
2+ messages / 2 participants
[nested] [flat]
* trouble with query
@ 2003-03-18 14:47 alexj <alexj@freesurf.ch>
0 siblings, 1 reply; 2+ messages in thread
From: alexj @ 2003-03-18 14:47 UTC (permalink / raw)
To: pgsql-sql
Hi,
I'm looking how can I do to insert multiple values from a
complexe query.
What I want to do is something like that :
INSERT INTO est_planifie_jour (id,ref_activite,ref_ressource,ref_jour)
(SELECT nextval('est_p_id_p') FROM est_planifie),
(SELECT id_activite FROM activite WHERE
nom = 'SGBD 02 cours théorique),
(SELECT ref_ressource FROM personne,groupe,fait_partie
WHERE groupe.nom ='cycle 1b' AND
fait_partie.ref_groupe = groupe.id_groupe AND
personne.id_personne = fait_partie.ref_personne),
(SELECT id_jour FROM jour WHERE jour.id_jour = 3)
Does anyone can advice me ?
--
/**
* Alexandre Jaquet
*/
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: trouble with query
@ 2003-03-19 18:49 jasiek@klaster.net
parent: alexj <alexj@freesurf.ch>
0 siblings, 0 replies; 2+ messages in thread
From: jasiek@klaster.net @ 2003-03-19 18:49 UTC (permalink / raw)
To: alexj <alexj@freesurf.ch>; +Cc: pgsql-sql
On Tue, Mar 18, 2003 at 03:47:55PM +0100, alexj wrote:
> Hi,
>
> I'm looking how can I do to insert multiple values from a
> complexe query.
>
> What I want to do is something like that :
>
> INSERT INTO est_planifie_jour (id,ref_activite,ref_ressource,ref_jour)
> (SELECT nextval('est_p_id_p') FROM est_planifie),
> (SELECT id_activite FROM activite WHERE
> nom = 'SGBD 02 cours théorique),
> (SELECT ref_ressource FROM personne,groupe,fait_partie
> WHERE groupe.nom ='cycle 1b' AND
> fait_partie.ref_groupe = groupe.id_groupe AND
> personne.id_personne = fait_partie.ref_personne),
> (SELECT id_jour FROM jour WHERE jour.id_jour = 3)
>
You should rewrite your insert to receive multiple rows from single
select. This query shoud be similiar to this below:
insert into ... (..)
select
nextval('est_p_id_p'),
id_activite,
ref_resource,
ref_jour
from
activite, personne,groupe,fait_partie,jour
where
activite.nom='..' and fait_partie.ref_groupe=groupe.id_groupe
and groupe.nom='..'
and jour.id_jour=3
Regards,
Tomasz Myrta
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2003-03-19 18:49 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2003-03-18 14:47 trouble with query alexj <alexj@freesurf.ch>
2003-03-19 18:49 ` 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