From: | Naval Grau <enventa2000(at)yahoo(dot)com> |
---|---|
To: | pgsql-novice(at)postgresql(dot)org |
Subject: | Re: last mail a bit confusing,sorry |
Date: | 2003-01-04 16:19:41 |
Message-ID: | 20030104161941.78625.qmail@web9702.mail.yahoo.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-novice |
Hi again:
I meant you can use this:
INSERT INTO cards_type_temp
VALUES
(
'Vtes',
( SELECT card_name FROM cards_type ),
( SELECT card_type FROM cards_type ),
( SELECT record_num FROM cards_type )
)
;
I put an extra parenthesis in the other mail.
Goodbye.
--- Naval Grau <enventa2000(at)yahoo(dot)com> wrote:
> Hi:
>
> I would better try this. This selects only one row
> at
> a time.
>
>
> INSERT INTO "cards_type_temp"
> (
> "card_game",
> "card_name",
> "card_table",
> "record_num"
> )
> VALUES
> (
> 'Vtes',
> ( SELECT "card_name" FROM "cards_type" ),
> ( SELECT "card_type" FROM "cards_type" ),
> ( SELECT "record_num" FROM "cards_type" )
> )
> );
>
>
> Probably the DB understands that everything between
> two commas in VALUES is supossed to fit into a
> single
> column.
>
> So, in the statement you made, if it had worked, you
> would be setting only two columns, and the DB would
> have set the last two columns to NULL.
>
> Incidentally, I didn't know you could put "" (double
> quotes?) in a psql statement. I'm surprised that
> psql
> even accepted them.
>
> I never use "" anywhere and have not had any
> problem.
> I use JSP and Java to access psql and I if I had to
> use " the I would just go crazy while trying to
> insert
> correctly all those \" characters in every string.
> Argh! I hate "".
>
> Perhaps you used "" to make this mail clearer, or
> perhaps you needed it in Mysql. In psql you don't
> need
> either especifying every time what columns you are
> inserting! It's more correct, but sometimes you are
> in
> a hurry...
>
>
>
> --- Chris Boget <chris(at)wild(dot)net> wrote:
> > I've read through the docs and I couldn't find
> many
> > examples of using
> > subselects. I could find out and read all about
> > what they were, but not
> > many examples. If someone could point to a page
> > that does show this,
> > I'd be ever so appreciative!
> > Anyways, I'm redoing a table I imported from MySQL
> > (as part of my
> > conversion to PG from MySQL) and I'm having
> problems
> > with this. The
> > error I'm getting is that it says you can't select
> > more than one column.
> > Why? Is there another way to do what I'm trying?
> > Here is my query:
> >
> > INSERT INTO "cards_type_temp"
> > ( "card_game", "card_name", "card_table",
> > "record_num" )
> > VALUES
> > ( 'Vtes', ( SELECT "card_name", "card_type",
> > "record_num" FROM "cards_type" ));
> >
> > Any help or insight would be great!
> >
> > Chris
> >
> >
> > ---------------------------(end of
> > broadcast)---------------------------
> > TIP 1: subscribe and unsubscribe commands go to
> majordomo(at)postgresql(dot)org
>
>
> =====
> Enrique Naval
> Estudiante de Informtica de Gestin en la Udl
> (Lleida)
> Lleida
>
> __________________________________________________
> Do you Yahoo!?
> Yahoo! Mail Plus - Powerful. Affordable. Sign up
> now.
> http://mailplus.yahoo.com
>
> ---------------------------(end of
> broadcast)---------------------------
> TIP 6: Have you searched our list archives?
>
> http://archives.postgresql.org
=====
Enrique Naval
Estudiante de Informtica de Gestin en la Udl (Lleida)
Lleida
__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com
From | Date | Subject | |
---|---|---|---|
Next Message | Andrew McMillan | 2003-01-05 05:00:49 | Re: Subselects to populate a table |
Previous Message | Naval Grau | 2003-01-04 15:48:56 | Re: Subselects to populate a table (and "" and making things correct) |