I'm translating some data.frame code into SQL by using sqldf. My goal here is to subset rows of a data.frame A using a column from B. Is this possible when A and B don't share any column names?
A = data.frame(a1 = c(1:4), a2 = c(101:104))
B = data.frame(b1 = c(1:2), b2 = c(55,56))
A[A$a1 %in% B$b1,]
## a1 a2
## 1 1 101
## 2 2 102
I can subset A if I already know the values from B$b1, but that's not very scalable.
sqldf("select * from A where a1 in (1,2)")
Do I need an inner join and/or is it required to have identical column names?