Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Problem with renaming a field in sql table

So i have this table:

mysql> SELECT * FROM artists LIMIT 5; 

    +----+----------------+------------+----------+----------------+--------+--------+
    | id | name           | start_year | end_year | origin         | type   | gender |
    +----+----------------+------------+----------+----------------+--------+--------+
    |  4 | Massive Attack |       1987 |     NULL | United Kingdom | Group  | NULL   |
    | 17 | Bob Dylan      |       1941 |     NULL | United States  | Person | Male   |
    | 20 | Art of Noise   |       1983 |     2000 | United Kingdom | Group  | NULL   |
    | 25 | Pavement       |       1989 |     2000 | United States  | Group  | NULL   |
    | 29 | Stevie Wonder  |       1950 |     NULL | United States  | Person | Male   |
    +----+----------------+------------+----------+----------------+--------+--------+


mysql> SELECT name, end_year FROM artists WHERE name IN ("Black Box Recorder");

    +--------------------+----------+
    | name               | end_year |
    +--------------------+----------+
    | Black Box Recorder |     2010 |
    +--------------------+----------+

I then make the table smaller to show what i want to rename which is the end year, and i want to change it to NULL. I have tried this command:

UPDATE artists SET end_year='NULL' WHERE name='Black Box Recorder';

and i thought this command should be correct but it gives this error:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

ERROR 1366 (HY000): Incorrect integer value ‘NULL’ for column
‘end_year’ at row 155

>Solution :

Please remove quotes from ‘NULL’ in your update statement.

UPDATE artists SET end_year=NULL WHERE name='Black Box Recorder'; 
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading