1
0

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.

【エラー】unknown column '~' in 'field ~'

Posted at

エラー

DBにデータを保存したいのに出来ない…
コンソールを確認したところ下記のエラー:eyes:

unknown column 'question_id' in 'field list'

原因

question_idは、questionsテーブルの中にあるのに、correct_answersって書いてた…:baby_tone1:

String sql = "INSERT INTO correct_answers (question_id, answer, created_at, updated_at) values (?,?,current_timestamp(),current_timestamp())";

まとめ

記事少ないと思ったらこんなヘナチョコミスかよ。
もうこんなミスしたくない:hugging:
今後同じエラーがでた時のためにも備忘録。

①データベースエラーだったらまずDBに関わる部分全部確認すること
・DAOのSQL文、Beanのカラム名、DBのカラム名が同じか
・DAOのSQL文のテーブル名間違ってないか

②コンソールを細かく確認チェック!
・エラー文の一文だけじゃなく、他の行も読む

以上

1
0
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
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?