Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Returning ERROR: column does not exist in where clause (POSTGRESQL)

Tags:

sql

postgresql

I need to select a table, but it's keeping returning error when i tried to using "where" for some column.

here's my code, and i attach an image file for detail.

sirima=# select * from sirima.program_studi;
 kode |      nama       |  jenis_kelas  |          nama_fakultas          | jenjang
------+-----------------+---------------+---------------------------------+---------
    1 | Kedokteran      | Reguler       | Kedokteran                      | S1
    2 | Matematika      | Reguler       | Matematika dan Pengetahuan Alam | S1
    3 | Teknik Sipil    | Reguler       | Teknik                          | S1
    4 | Ilmu Komputer   | Reguler       | Ilmu Komputer                   | S1
    5 | Kedokteran      | Reguler       | Kedokteran                      | S2
    6 | Fisika          | Reguler       | Matematika dan Pengetahuan Alam | S2
    7 | Teknik Sipil    | Reguler       | Teknik                          | S2
    8 | Ilmu Komputer   | Reguler       | Ilmu Komputer                   | S2
    9 | Kedokteran      | Reguler       | Kedokteran                      | S3
   10 | Biologi         | Reguler       | Matematika dan Pengetahuan Alam | S3
   11 | Teknik Sipil    | Reguler       | Teknik                          | S3
   12 | Ilmu Komputer   | Reguler       | Ilmu Komputer                   | S3
   13 | Kedokteran      | Internasional | Kedokteran                      | S1
   14 | Biologi         | Internasional | Matematika dan Pengetahuan Alam | S1
   15 | Teknik Industri | Internasional | Teknik                          | S1
   16 | Ilmu Komputer   | Internasional | Ilmu Komputer                   | S1
   17 | Kedokteran      | Paralel       | Kedokteran                      | S1
   18 | Biologi         | Paralel       | Matematika dan Pengetahuan Alam | S1
   19 | Teknik Industri | Paralel       | Teknik                          | S1
   20 | Ilmu Komputer   | Paralel       | Ilmu Komputer                   | S1
(20 rows)

sirima=# select * from sirima.program_studi where jenis_kelas = "Reguler";
ERROR:  column "Reguler" does not exist
LINE 1: ...t * from sirima.program_studi where jenis_kelas = "Reguler";

ERROR PICT DETAIL

like image 926
maghfirzakir Avatar asked May 12 '17 20:05

maghfirzakir


2 Answers

use single quotes:

select * from sirima.program_studi where jenis_kelas = 'Reguler';

https://www.postgresql.org/docs/current/static/sql-syntax-lexical.html:

like image 132
Vao Tsun Avatar answered Oct 02 '22 09:10

Vao Tsun


Double quotes are for identifiers while single quotes are for strings.

where jenis_kelas = 'Reguler'
like image 37
Clodoaldo Neto Avatar answered Oct 02 '22 09:10

Clodoaldo Neto