Skip to content
Advertisement

How to compose query properly using dbGetQuery command?

I have a small database in PostgresSQL. And I connected to it via R-studio and try to retrieve data from database.

I wrote a command, but it doesn’t work. And I don’t know what’s the problem. Please, help me.

So, the code works well.

But these two codes fail

Where con is the postgres connection object.

And of course query with any combination of these vars gives an error.

I would be thankful to all of you if you help me.

Advertisement

Answer

You need to properly quote the odd names:

Single quotes in PostgreSQL are used to create a text string, double quotes are used to name an identifier without changing its case.

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement