Search code examples
postgresqlstring-constant

Basic DELETE commands in PostgreSQL detecting value as column name


I'm trying to delete a row at PostgreSQL using pgAdmin4. Here is my command:

DELETE FROM commissions_user 
WHERE first_name = "Steven";

For some reason, the error states that

ERROR:  column "Steven" does not exist
LINE 2: WHERE first_name = "Steven";
                           ^
SQL state: 42703
Character: 50

It's weird, why is "Steven" detected as a column name, shouldn't the column name be first_name?


Solution

  • Use single quotes instead

    DELETE FROM commissions_user 
    WHERE first_name = 'Steven';
    

    Double quotes can be used table and column, and single quotes can be used for strings.

    ex.

    DELETE FROM "commissions_user"
    WHERE "first_name" = 'Steven';