0

Hello in the following MySQL query I am attempting to insert a string where it says "notes" but I keep getting an error and the data does not submit. However, if I pass a number it successfully works.

`insert into lecture_notes(teacher_id, class_id, notes, sent_on)
values(?,?,?, now());`, 
      [
          data1, data2, "testing testing"
      ],

//Following is the error I keep getting { "success": 0, "data": "Error. Unable to post notes.", "error_type": { "code": "ER_BAD_FIELD_ERROR", "errno": 1054, "sqlMessage": "Unknown column 'notes' in 'field list'", "sqlState": "42S22", "index": 0, "sql": "insert into lecture_notes(teacher_id, class_id, notes, sent_on)\n values(28,27,note, now());" } }

7
  • 2
    I keep getting an error: please edit your question to show the full error message. Commented Oct 13, 2020 at 17:49
  • What is the datatype of column notes? Commented Oct 13, 2020 at 17:50
  • Also add the response of desc lecture_notes; so that the data types can be seen properly. Commented Oct 13, 2020 at 17:50
  • @GMB Its varchar(80) utf8mb4_unicode_ci Commented Oct 13, 2020 at 17:52
  • I edited my question and added the error I keep seeing Commented Oct 13, 2020 at 17:55

1 Answer 1

2

Unknown column 'notes' in 'field list' This clearly means that your table does not have any column named notes. Correct the column name.

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

4 Comments

Thank you for your reply but I do have that column. So thats not the issue because when I pass a number instead of a string to test it, it works. But not when I pass a string.
I got it to work now. There was a syntax error in my code before hitting this query. Thank you..
Was it about the column name or about the data type? If it worked, do upvote please
It was somewhat related to that. But not specifically the column name because the name was matching. It was how I was passing the data into that column. Gave you upvote. Thanks

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.