1

I'm running PostgreSQL version 9.5.1 on my Mac - I'm trying to make a simple insert statement, but it's spitting an error that I don't quite understand... for some reason, it seems to think that one of the values that I'm inserting is actually one of the column names. Here's the scenario...

\d+ group_members

Column      |            Type             |
------------+-----------------------------+
id          | integer                     |
group_id    | integer                     |
user_id     | integer                     |
role        | character varying(255)      |
inserted_at | timestamp without time zone |
updated_at  | timestamp without time zone |

Indexes:
  "group_members_pkey" PRIMARY KEY, btree (id)
  "group_members_group_id_index" btree (group_id)
  "group_members_user_id_index" btree (user_id)

When I try to run

insert into group_members (group_id, user_id, role, inserted_at, updated_at)
values (1, 2, ’member’, current_timestamp, current_timestamp);

I get the error:

ERROR:  column "’member’" does not exist
LINE 1: ...user_id,role,inserted_at,updated_at) values (1,2,’member’,c...
                                                            ^

Well yes, I agree, the column 'member' does not exist... but I'm not sure I understand why PostgreSQL thinks that this is my intention. I have made numerous inserts into other tables and had now such problem but I can't seem to insert into this table. Can anyone see where I've gone wrong?

1 Answer 1

5

Replace ’member’ with 'member' .

It seems you dont have single quote. it is some other char

Sign up to request clarification or add additional context in comments.

3 Comments

Holy crap, you're right! I have no idea how that happened, I'm not kidding. I had a feeling this would be some embarrassing error on my part.
Well, this happens. Happy Coding!
This solved it for me in Spring Boot too! thank you

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.