簡體   English   中英

如何使用鍵從另一個表插入數據?

[英]How to insert data from another table with keys?

我在 Postgresql 中做了這個 SELECT,以測試我在我的項目中需要哪些列,我也卡住了,需要幫助。

SELECT 
  trb.id,
  id_cliente,
  id_usuario,
  usu.nome_acesso,
  id_contribuinte,
  to_char(data_mensagem, 'MM/DD/YYYY')
  ,
  assunto,
  mensagem
FROM 
  el_trb_mensagem.trb_mensagem trb
  left join el_acesso.gg_usuario usu on (usu.id = trb.id_usuario)

下一步是進行插入,但是對於 postgres 網站文檔的基本語法,我不明白,但我認為它比看起來更簡單。

insert into <destination table> (<destination columns' names>)
<your select>

例如

insert into table (id,name) select another_id, another_name from another_table

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM