Re: Subselects to populate a table (and "" and making things correct)
| От | Naval Grau |
|---|---|
| Тема | Re: Subselects to populate a table (and "" and making things correct) |
| Дата | |
| Msg-id | 20030104154856.76208.qmail@web9702.mail.yahoo.com обсуждение исходный текст |
| Ответ на | Subselects to populate a table ("Chris Boget" <chris@wild.net>) |
| Ответы |
Re: last mail a bit confusing,sorry
|
| Список | pgsql-novice |
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@wild.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@postgresql.org ===== Enrique Naval Estudiante de Inform�tica de Gesti�n en la Udl (Lleida) Lleida __________________________________________________ Do you Yahoo!? Yahoo! Mail Plus - Powerful. Affordable. Sign up now. http://mailplus.yahoo.com
В списке pgsql-novice по дате отправления: