0
将列插入到另一个表中我已经使用RPostgreSQL来连接R和postgresQL,并且我想根据“pid”在另一个表中插入一列,请告知如何可以使用R指令来实现:RPostgreSQL-根据ID
>library(RPostgreSQL)
>drv<-dbDriver("PostgreSQL")
>itemlist<- dbGetQuery(con, "SELECT * from project_budget_itemlist")
>View(itemlist)
pid item cost
1 ABC 9
2 ACB 8
3 BAC 7
3 ZZZ 6
和另一表是如下:
>name<- dbGetQuery(con, "SELECT * from namelist")
>View(name)
pid name
1 Sally
2 Joy
3 Susan
欲得到的结果是:
pid item cost name
1 ABC 9 Sally
2 ACB 8 Joy
3 BAC 7 Susan
3 ZZZ 6 Susan
也许'?merge'? (你想要一个预期结果的数据集或者将预期结果写回postgres?) – Tensibai
@Tensibai:嗨,不需要在postgres中返回结果。我只是想组合并做一些情节。 – Samoth
在这种情况下'合并(itemlist,name)'应该这样做... – Tensibai