Last answered:

22 Jun 2020

Posted on:

21 Jun 2020

0

DEFAULT constraint

Hello 365  Please I gave the query statement but its giving me the error message  Error Code: 1054 Unknown column 'last_name' in 'field list' INSERT INTO customers (first_name, last_name, gender)
VALUES ('Peter', 'Figaro', 'M')
;   Please what did I do wrong  
1 answers ( 0 marked as helpful)
Instructor
Posted on:

22 Jun 2020

0

Hi Ashakah!
Thanks for reaching out.
Please make sure you don't skip any lecture or exercise while taking this course. We gradually modify the contents of our data tables and it is essential that you don't skip any steps.
That said, it seems that currently you don't have a field called last_name in your customers table. Please make sure you've completed the exercise of the UNIQUE Constraint lecture - https://learn.365datascience.com/courses/sql/unique-constraint (which is the lecture preceding the one you are referring to).
In other words, please make sure to have created and altered the customers table by executing the following code:

CREATE TABLE customers (
customer_id INT AUTO_INCREMENT,
first_name VARCHAR(255),
last_name VARCHAR(255),
email_address VARCHAR(255),
number_of_complaints INT,
PRIMARY KEY (customer_id)
);
ALTER TABLE customers
ADD COLUMN gender ENUM('M', 'F') AFTER last_name;

After you can confirm that you have done that, please retry executing the code you've posted in your question.
Hope this helps but please feel free to get back to us should you need further assistance. Thank you.
Best,
Martin

Submit an answer