I have two tables; viz table1 = PID (primary key) + 20 other columns & 200 records from database1 AND table2 = [Serial no] (primary key) + 10 other columns & 300 records from database2.
I am trying to extract values from table2 where PID = [Serial no].
Note: PID = [SCK34ICV7, NSCK876DL, ......].
I refered "Pass string Variable in R script to use it in SQL statement"
t1 <- sqlquery(db1, "select * from table1")
r1 <- t1$PID
class(r1) = 'factor'
t2 <- sqlquery(db2, "select * from table2 where [Serial no] = '(",r1,")' ",sep ="")
I also tried other functions viz paste0(), fn$ from gsubfn and sprintf() and getting error like - 'c is not a recognized built in function name' ; 'Incorrect syntax'.
Please suggest the best way to do it.
Reg,
Mrutyunjaya