skip to Main Content

I have simple question why I am not able to simply INPUT value in my table with attribute desc? I want to know this just for inf. I can change in table attribute name any time.

I did what allways INPORT value in attribute but when i came to this name of attribute then i get error. Whith any other name of attribute i don´t have this kind of problem.

INSERT INTO table (name, size, desc) VALUES ("problem", "huge", "not able to inport description value");

2

Answers


  1. What flavour of SQL are you using? DESC is a reserved word in MySQL, Postgres and others. There is a good list here.

    desc is normally used for ordering results. It is short for descending.

    Login or Signup to reply.
  2. You have several errors in your statement

    The SQL statement to create a new row is INSERT, not INPUT

    desc is a reserved keyword, so you need to use double quotes: "desc" to refer to the column.

    And finally: string constants need to be enclosed in single quotes in SQL.

    Putting that all together, you need to use:

    INSERT INTO table (name, size, "desc") 
    VALUES ('problem', 'huge', 'not able to inport description value');
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search