Why did sqldf in R give this syntax error?

66 views Asked by At

I tried package sqldf in R. I tried a very easy join. However, I got this syntax error.

library(sqldf)

radius1 <- sqldf("select radius.*, all.height, all.bmi
                  from radius left join all
                  on radius.uID = all.study_id
                 ")

Error: near "all": syntax error

What is wrong?

1

There are 1 answers

0
Tushar On BEST ANSWER

As neilfws has rightly pointed out; all is a reserved keyword in SQL queries and so is the syntax error.

If you still want to use "all" table name; you can surround it using backticks as below :

library(sqldf)

radius1 <- sqldf("select radius.*, `all`.height, `all`.bmi
                  from radius left join `all`
                  on radius.uID = `all`.study_id
                 ")