Postgres Inner Join Select query returns error: column does not exist

new*_*ere 4 sql postgresql

I have been reading through the documentation and I can't find what I'm doing wrong here.

I'm executing this query:

SELECT *
FROM "parts"
INNER JOIN "categories" ON "categories"."id" = "parts"."category_id"
WHERE "categories"."name" = "cars"
Run Code Online (Sandbox Code Playgroud)

And I'm getting this error:

ERROR:  column "cars" does not exist
LINE 3: WHERE (categories.name = "cars")
                                 ^
********** Error **********

ERROR: column "cars" does not exist
SQL state: 42703
Character: 122
Run Code Online (Sandbox Code Playgroud)

Category Table:

CREATE TABLE categories
(
  id serial NOT NULL,
  name character varying(255),
  CONSTRAINT categories_pkey PRIMARY KEY (id)
)
Run Code Online (Sandbox Code Playgroud)

Parts Table:

CREATE TABLE parts
(
  id serial NOT NULL,
  category_id integer,
  CONSTRAINT parts_pkey PRIMARY KEY (id)
)
Run Code Online (Sandbox Code Playgroud)

Any help would be greatly appreciated.

Laj*_*res 8

您应该使用单撇号作为字符串常量:

SELECT *
FROM "parts"
INNER JOIN "categories" ON "categories"."id" = "parts"."category_id"
WHERE "categories"."name" = 'cars'
Run Code Online (Sandbox Code Playgroud)

双精度意味着数据库对象.(字段,表格等)

(否则它们不是必需的,仅用于额外的,例如名称中的空格等)