잠시만 기다려 주세요

     '시장이나 돌면서 가짜 민생 외치는 이재명을 규탄한다. 싸우지 않을 거면 내려와라... 야당대표는 당신의 방탄이나 하는 자리가 아니다.'
전체검색 :  
이번주 로또 및 연금번호 발생!!   |  HOME   |  여기는?   |  바다물때표   |  알림 (19)  |  여러가지 팁 (1095)  |  추천 및 재미 (163)  |  자료실 (28)  |  
시사, 이슈, 칼럼, 평론, 비평 (799)  |  끄적거림 (142)  |  문예 창작 (719)  |  바람 따라 (75)  |  시나리오 (760)  |  드라마 대본 (248)  |  
살인!


    postgresql

postgresql - How to do an update + join in PostgreSQL?, 업데이트시 조인 방법
이 름 : 바다아이   |   조회수 : 7789         짧은 주소 : https://www.bada-ie.com/su/?531592701414
아래 두가지 예제를 보시면 될 거 같습니다
조인 형태에 update 입니다.


[ WITH [ RECURSIVE ] with_query [, ...] ]
UPDATE [ ONLY ] table [ [ AS ] alias ]
    SET { column = { expression | DEFAULT } |
          ( column [, ...] ) = ( { expression | DEFAULT } [, ...] ) } [, ...]
    [ FROM from_list ]
    [ WHERE condition | WHERE CURRENT OF cursor_name ]
    [ RETURNING * | output_expression [ [ AS ] output_name ] [, ...] ]

In your case I think you want this:


예제1)

UPDATE vehicles_vehicle AS v 
SET price = s.price_per_vehicle
FROM shipments_shipment AS s
WHERE v.shipment_id = s.id 


예제2)

UPDATE a
SET price = b_alias.unit_price
FROM      a AS a_alias
LEFT JOIN b AS b_alias ON a_alias.b_fk = b_alias.id
WHERE a_alias.unit_name LIKE 'some_value' 
AND a.id = a_alias.id
--the below line is critical for updating ONLY joined rows
AND a.pk_id = a_alias.pk_id;


출처 : https://stackoverflow.com/questions/7869592/how-to-do-an-update-join-in-postgresql
| |





      1 page / 2 page
번 호 카테고리 제 목 이름 조회수
45 postgresql postgresql ... postgresql 14 .. postgresql.conf port 5432 .. 바다아이 1848
44 postgresql , count(*) .... 바다아이 8516
현재글 postgresql How to do an update + join in PostgreSQL?, 바다아이 7790
42 postgresql sequence(퀀) 바다아이 10258
41 postgresql , , , index create, , 바다아이 10247
40 postgresql postgresql log_timezone .... 바다아이 8294
39 postgresql postgresql SEQUENCE reset .... 바다아이 10222
38 postgresql [PostgreSql] WITH , , Operator 바다아이 9437
37 postgresql postgresql for, foreach , 바다아이 11220
36 postgresql postgresql , , into ... 바다아이 11352
35 postgresql postgresql PL/pgSQL - SQL Procedural Language, , 바다아이 12929
34 postgresql postgresql ... .. , , 바다아이 14466
33 postgresql postgresql CSV export/import 바다아이 10595
32 postgresql postgresql tablespace , .... 바다아이 15810
31 postgresql postgresql 10 partitioning, ... , ... 바다아이 11139
30 postgresql Using PostgreSQL Arrays, ... ... 바다아이 11174
29 postgresql PostgreSQL (TRIGGER) (function) 바다아이 10736
28 postgresql Optimize and Improve PostgreSQL Performance with VACUUM, ANALYZE, and REINDEX 바다아이 11355
27 postgresql postgresql tuple . vacuumdb .. , . 바다아이 10948
26 postgresql postgresql , .. 바다아이 11151
25 postgresql postgresql , size, 바다아이 13073
24 postgresql postgresql , , .... 바다아이 9915
23 postgresql PostgreSQL Replication, , , master, slave 바다아이 13504
22 postgresql postgresql case 바다아이 9972
21 postgresql postgresql with 바다아이 10418
20 postgresql postgresql , , string 바다아이 14363
19 postgresql Postgresql partitioning table , , , 바다아이 10786
18 postgresql PostgreSQL 바다아이 12424
17 postgresql postgresql vacuumdb, psql, pg_dump password crontab , pgpass 바다아이 12401
16 postgresql postgresql sequence 퀀 auto_increment . 바다아이 11343
| |









Copyright ⓒ 2001.12. bada-ie.com. All rights reserved.
이 사이트는 리눅스에서 firefox 기준으로 작성되었습니다. 기타 브라우저에서는 다르게 보일 수 있습니다.
[ Ubuntu + GoLang + PostgreSQL + Mariadb ]
서버위치 : 오라클 클라우드 춘천  실행시간 : 0.22694
to webmaster... gogo sea. gogo sea.