“Perbarui CON SELECT POSTGRESQL” Kode Jawaban

Postgres Update dengan If Condition Query

update t1
        set t1.current_location =   
        CASE  
			WHEN SUBQUERY.status = 0 THEN 'Deployed' 
			WHEN SUBQUERY.status = 1 THEN 'Retrieved' 
			WHEN SUBQUERY.status = 2 THEN 'Lost' 
            ELSE t1.current_location
		END 
from (
    select t3.serial_number, t2.status
    from t2 inner join t3
        on t2.some_id = t3.some_id
    ) as SUBQUERY

where SUBQUERY.serial_number = t1.serial_number;
Thoughtful Tuatara

Perbarui CON SELECT POSTGRESQL

UPDATE dummy
SET customer=subquery.customer,
    address=subquery.address,
    partn=subquery.partn
FROM (SELECT address_id, customer, address, partn
      FROM  /* big hairy SQL */ ...) AS subquery
WHERE dummy.address_id=subquery.address_id;
omargt8

UPDATE DARI Pilih PostGresQL

UPDATE
  <table1>
SET
  customer=subquery.customer,
  address=subquery.address,
  partn=subquery.partn
FROM
  (
    SELECT
      address_id, customer, address, partn
    FROM  /* big hairy SQL */ ...
  ) AS subquery
WHERE
  dummy.address_id=subquery.address_id;
Black Buffalo

Jawaban yang mirip dengan “Perbarui CON SELECT POSTGRESQL”

Pertanyaan yang mirip dengan “Perbarui CON SELECT POSTGRESQL”

Lebih banyak jawaban terkait untuk “Perbarui CON SELECT POSTGRESQL” di Sql

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya