3

I am trying to query from a database called physionet-data.mimiciii_clinical.diagnoses_icd

PostgresSQL returns the following error message:

quan.sql:273: ERROR:  syntax error at or near "`"
LINE 132: from `physionet-data.mimiciii_clinical.diagnoses_icd` icd

I think it is caused by the dash. If I change the `for ' the same error comes up

quan.sql:273: ERROR:  syntax error at or near
"'physionet-data.mimiciii_clinical.diagnoses_icd'"

Any clue on how to fix that?

1

1 Answer 1

3

You would need to quote that schema name, using double-quotes:

select ...
from "physionet-data".mimiciii_clinical.diagnoses_icd

Note that quoting an identifier makes it case-sensitive. You would need to ensure that the character case the schema was created with matches the one you are using here.

Using identifiers that require quoting is not a good idea in general; as you are fiding out, this requires quoting them every where you use it later on. If that's not too late, I would recommend changing the schema name to a name that does not require quoting.

Sign up to request clarification or add additional context in comments.

4 Comments

Hi @GMB! Thank you for your swift response :) Unfortunately, I can't change the schema name, it's a public db... I tried your solution but it did not work out. I got: LINE 132: from "physionet-data".mimiciii_clinical.diagnoses_icd icd ^ Could this be because the from goes first in the code, as follows: from "physionet-data".mimiciii_clinical.diagnoses_icd icd where ... select ... The Github page for the code is there: github.com/MIT-LCP/mimic-code/blob/master/concepts/comorbidity/…
Could you explain a bit more what you mean by "You would need to ensure that the character case the schema was created with matches the one you are using here" please ?
@LucileTer-Minassian: I mean that if your schema was created with mixed upper/lower case, then you need to use that in your query. See: wiki.postgresql.org/wiki/…
oh, I see! I think the schema is all lower case so we're good on that side. but if double quotation marks don't work, are there other alternatives?

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.