pg.ddx.io pgsql-general@postgresql.org mailing list archive
help / color / mirror / Atom feedQuery a column with the same name as an operator
3+ messages / 3 participants
[nested] [flat]
* Query a column with the same name as an operator
@ 2020-11-06 08:59 Java Developer <java@wagemaker.co.uk>
2020-11-06 09:08 ` Re: Query a column with the same name as an operator Magnus Hagander <magnus@hagander.net>
0 siblings, 1 reply; 3+ messages in thread
From: Java Developer @ 2020-11-06 08:59 UTC (permalink / raw)
To: pgsql-general@lists.postgresql.org
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?
Many Thanks
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: Query a column with the same name as an operator
2020-11-06 08:59 Query a column with the same name as an operator Java Developer <java@wagemaker.co.uk>
@ 2020-11-06 09:08 ` Magnus Hagander <magnus@hagander.net>
2020-11-06 09:24 ` Re: Query a column with the same name as an operator Jurrie Overgoor <postgresql-mailinglist@jurr.org>
0 siblings, 1 reply; 3+ messages in thread
From: Magnus Hagander @ 2020-11-06 09:08 UTC (permalink / raw)
To: java@wagemaker.co.uk; +Cc: pgsql-general <pgsql-general@lists.postgresql.org>
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.
--
Magnus Hagander
Me: https://www.hagander.net/
Work: https://www.redpill-linpro.com/
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: Query a column with the same name as an operator
2020-11-06 08:59 Query a column with the same name as an operator Java Developer <java@wagemaker.co.uk>
2020-11-06 09:08 ` Re: Query a column with the same name as an operator Magnus Hagander <magnus@hagander.net>
@ 2020-11-06 09:24 ` Jurrie Overgoor <postgresql-mailinglist@jurr.org>
0 siblings, 0 replies; 3+ messages in thread
From: Jurrie Overgoor @ 2020-11-06 09:24 UTC (permalink / raw)
To: pgsql-general@lists.postgresql.org
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
^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2020-11-06 09:24 UTC | newest]
Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2020-11-06 08:59 Query a column with the same name as an operator Java Developer <java@wagemaker.co.uk>
2020-11-06 09:08 ` Magnus Hagander <magnus@hagander.net>
2020-11-06 09:24 ` Jurrie Overgoor <postgresql-mailinglist@jurr.org>
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