I'm trying to do a left join using sqldf package on R.
data <- sqldf(
" SELECT a.*, b.var1, b.var2, b.id
FROM table1 as a LEFT JOIN table2 as b
ON a.id=b.id "
)
Unfortunately I get two columns named "id" in data. How can I avoid this problem?
Thanks
Chloé
Note that the code is asking for two id's as
a.*includes allacolumns and it explicitly asked forb.id. You can simply drop theb.idor if you want all
bcolumns except id then useUSINGinstead ofONIf you do want two id's but just named differently then this will name the
b.idasid2.