Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kay09-0000kn-10 for pgsql-general@arkaria.postgresql.org; Fri, 06 Nov 2020 09:25:45 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kaxzc-0007v0-GV for pgsql-general@arkaria.postgresql.org; Fri, 06 Nov 2020 09:25:12 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kaxzc-0007ue-8k for pgsql-general@lists.postgresql.org; Fri, 06 Nov 2020 09:25:12 +0000 Received: from smtpq3.tb.mail.iss.as9143.net ([212.54.42.166]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kaxzW-0003SB-Ae for pgsql-general@lists.postgresql.org; Fri, 06 Nov 2020 09:25:09 +0000 Received: from [212.54.42.110] (helo=smtp7.tb.mail.iss.as9143.net) by smtpq3.tb.mail.iss.as9143.net with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kaxzS-0000qJ-61 for pgsql-general@lists.postgresql.org; Fri, 06 Nov 2020 10:25:02 +0100 Received: from 94-213-48-205.cable.dynamic.v4.ziggo.nl ([94.213.48.205] helo=server) by smtp7.tb.mail.iss.as9143.net with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kaxzR-000174-SU for pgsql-general@lists.postgresql.org; Fri, 06 Nov 2020 10:25:01 +0100 Received: from 94-213-48-205.cable.dynamic.v4.ziggo.nl ([94.213.48.205] helo=[192.168.183.112]) by server with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.93) (envelope-from ) id 1kaxzQ-002l40-0W for pgsql-general@lists.postgresql.org; Fri, 06 Nov 2020 10:25:00 +0100 Subject: Re: Query a column with the same name as an operator To: pgsql-general@lists.postgresql.org References: From: Jurrie Overgoor Message-ID: <8faf2c93-46fe-6648-fd22-edabd18271f4@jurr.org> Date: Fri, 6 Nov 2020 10:24:59 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US X-SourceIP: 94.213.48.205 X-Authenticated-Sender: larixplein11@ziggo.nl (via SMTP) X-Ziggo-spambar: / X-Ziggo-spamscore: 0.0 X-Ziggo-spamreport: CMAE Analysis: v=2.4 cv=EM64b3VC c=1 sm=1 tr=0 ts=5fa5166d a=oSSSoXqxxMGH09P1CQz5lA==:17 a=9+rZDBEiDlHhcck0kWbJtElFXBc=:19 a=IkcTkHD0fZMA:10 a=nNwsprhYR40A:10 a=t61DQu2XAAAA:8 a=epTmVMiNAAAA:8 a=b5KrBkP8Qr6G3_qcgCoA:9 a=QEXdDO2ut3YA:10 a=cmW3kdE6juAA:10 a=9pKqXdp60mMA:10 a=T2oZsc1AbLKYfMksVV7R:22 a=ndEWmUVY6Yapc0oHF_P4:22 X-Ziggo-Spam-Status: No X-Spam-Status: No X-Spam-Flag: No List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 06-11-2020 10:08, Magnus Hagander wrote: > On Fri, Nov 6, 2020 at 10:00 AM Java Developer 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