While SQL is a special-purpose language that for the most part id declarative and set-based, R is a functional programming language. It is often difficult to do direct language translations. Using base R, you would probably use a merge()
command to bring different tables together.
If we have these sample tables
sheet1<-data.frame(
NAME_LAST=letters[1:10],
NAME_FIRST=letters[11:20],
SEX=sample(c("M","F"), 10, replace=T)
)
sheet2<-data.frame(
Last_Name=letters[1:10],
First_Name=letters[11:20],
ID = sample(100:200, 10)
)[sample(1:10), ]
sheet1;sheet2;
Then we can merge them with
mm<-merge(sheet1, sheet2,
by.x=c("NAME_LAST","NAME_FIRST"),
by.y=c("Last_Name","First_Name")
)
mm;
You can them probably subset this merged data set to get what you need.