| От | Nils Zonneveld |
|---|---|
| Тема | Re: Simple SQL question, need help. |
| Дата | |
| Msg-id | 3B0F67FE.5A1827A1@mbit.nl обсуждение |
| Список | pgsql-general |
feech wrote: > > I'm pretty much an idiot, but I can't figure out how to do this: > > I have a results DB with two fields: PlayerID and Position. I also > have a players DB with two fields: ID and Name. > > How do I insert a record into results with PlayerID selected from the > players DB and Position explicitly specified by me. > > Something like: > > INSERT INTO results (PlayerID, Position) values (SELECT players.id > from players WHERE name = 'Chuck', 4 ); > > That statement is trying to insert the player's ID (I only have his > name when inserting) and his position ( 4 in this case ), but it > doesn't work. > > Totally frustrated, > feech You can define the position as a constant in your resultset from the table player: insert into results select player_id, 4 as position from player where name = 'Chuck'; HTH, Nils Zonneveld
В списке pgsql-general по дате отправления:
Сайт использует файлы cookie для корректной работы и повышения удобства. Нажимая кнопку «Принять» или продолжая пользоваться сайтом, вы соглашаетесь на их использование в соответствии с Политикой в отношении обработки cookie ООО «ППГ», в том числе на передачу данных из файлов cookie сторонним статистическим и рекламным службам. Вы можете управлять настройками cookie через параметры вашего браузера