From: Jurrie Overgoor <postgresql-mailinglist@jurr.org>
To: pgsql-general@lists.postgresql.org
Subject: Re: Query a column with the same name as an operator
Date: Fri, 6 Nov 2020 10:24:59 +0100
Message-ID: <8faf2c93-46fe-6648-fd22-edabd18271f4@jurr.org> (raw)
In-Reply-To: <CABUevEwXcr079+tK8Ppq+dYtrigMwOVv2VndkwqUsADnTCeVyA@mail.gmail.com>
References: <b8dc10ca1d9148f271b557f872062a9af68c19da.camel@wagemaker.co.uk>
<CABUevEwXcr079+tK8Ppq+dYtrigMwOVv2VndkwqUsADnTCeVyA@mail.gmail.com>
On 06-11-2020 10:08, Magnus Hagander wrote:
> On Fri, Nov 6, 2020 at 10:00 AM Java Developer <java@wagemaker.co.uk> wrote:
>> Hello,
>>
>> I am trying to query a column from a table I migrated from my MYSQL
>> into POSTGRESQL but I seem to be having issues with a few column names.
>>
>> the column name cast is also an operator, I think zone may also be a
>> problem.
>>
>> MYSQL: OK
>> SELECT id, start_date, local_time, country, city, region, temperature,
>> cast, humidity, wind, weather, zone FROM w_records WHERE city =
>> 'Edinburgh' AND start_date LIKE '%2020-11-01%' ORDER BY id DESC;
>>
>> I can run the SELECT * from FROM w_records WHERE city = 'Edinburgh' but
>> the above does not work.
>>
>> Any idea how I can run a query that accept table name that is already a
>> Operator?
> Yes, cast is a keyword in SQL (not an operator). To use it as a column
> name you have to quote it, like
> SELECT "cast" FROM test
> (and the same when you create the table, or indeed any references to the column)
>
> zone is not, and should be fine.
There is a list of keywords available in the documentation here:
https://www.postgresql.org/docs/current/sql-keywords-appendix.html
Maybe it's of help to you.
Jurrie
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: postgresql-mailinglist@jurr.org
Subject: Re: Query a column with the same name as an operator
In-Reply-To: <8faf2c93-46fe-6648-fd22-edabd18271f4@jurr.org>
References: <b8dc10ca1d9148f271b557f872062a9af68c19da.camel@wagemaker.co.uk> <CABUevEwXcr079+tK8Ppq+dYtrigMwOVv2VndkwqUsADnTCeVyA@mail.gmail.com> <8faf2c93-46fe-6648-fd22-edabd18271f4@jurr.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox