Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQL script in R containing double quotes " [duplicate]

I am trying to run a query from R to an Oracle DB. Trouble is, that the string doesn't like the double quotes ". For example, I'd like to run the query:

 select T.* from xyz.table1 T where T."ID"='123'

In R this would work like this:

 sql<-"select T.* from xyz.table1 T where T."ID"='123'"

R returns an Error, saying:

 Error: unexpected symbol in sql<-"select T.* from xyz.table1 T where T."

Note: We need to use " around ID, as we want to force case-sensitivity, so that it doesn't match columns like: id, Id.

like image 748
Iztok Avatar asked Oct 18 '25 18:10

Iztok


1 Answers

You need to use a backslash \ to escape the double quotes.

The command you need is:

sql <- "select T.* from xyz.table1 T where T.\"ID\"='123'"
like image 57
Linford Bacon Avatar answered Oct 20 '25 06:10

Linford Bacon