10
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

[PostgreSQL] column "" does not exist の解決法

Posted at

概要

postgresqlの操作にはpgadminを使用しているのだが以下のqueryを実行したところErrorが発生した。

select * from users
where email like "%@%";
error
ERROR:  column "%@%" does not exist
LINE 2: where email like "%@%";
                         ^
SQL state: 42703
Character: 38

カラムの条件で"%@%"を指定しているのになんでってなった。

結論

どうやら " は列名を指定するときに使うらしい。
レコードを選択するときは列名と混同しないように ' を使わなければいけなかったのだ。
以下のクエリに変更したところ無事に動かすことができた。
めでたしめでたし。

select * from users
where email like '%@%';

参考文献

PostgreSQL - WHERE clause not working - Column name not found [duplicate]

10
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
10
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?