ERROR 1054 (42S22): Unknown column 'Firstname' in 'field list'

I'M gettin the above error when I enter:

mysql> insert into people (fname, lname)
    -> VALUES (Firstname, Lastname);

Here's the table:

mysql> desc people;
+-------------+-------------+------+-----+---------+-------+
| Field       | Type        | Null | Key | Default | Extra |
+-------------+-------------+------+-----+---------+-------+
| fname       | varchar(20) | YES  |     | NULL    |       |
| lname       | varchar(20) | YES  |     | NULL    |       |
| phonenumber | varchar(10) | YES  |     | NULL    |       |
| city        | varchar(20) | YES  |     | NULL    |       |
| state       | varchar(20) | YES  |     | NULL    |       |
| address     | varchar(30) | YES  |     | NULL    |       |
| zip         | varchar(5)  | YES  |     | NULL    |       |
+-------------+-------------+------+-----+---------+-------+

Any ideas?

Recommended Answers

I'm more of an MSSQL person myself, but wouldnt you have to enclose the values in single quotes? In SQL, if you dont use the single quotes, SQL considers the value as a column name.

Jump to Post

Missing quotes:

insert into people (fname, lname) VALUES ('Firstname', 'Lastname');
Jump to Post

All 6 Replies

I'm more of an MSSQL person myself, but wouldnt you have to enclose the values in single quotes? In SQL, if you dont use the single quotes, SQL considers the value as a column name.

Missing quotes:

insert into people (fname, lname) VALUES ('Firstname', 'Lastname');

Yes you are right. I am dumb. Thanks.

I am dumb.

C'mon, that's not right. So you didnt know, so what?

can you please help me with this?

import mysql.connector as sql

z='abc'
y='fhsvr'

mysql=sql.connect(host="localhost", user="root", passwd="root", database="data")

sqlc=mysql.cursor()
sqlc.execute("insert into reg_details(username, password) values(z,y)")
mysql.commit()

mysql.close()

Please start a new discussion asking your questin instead of "hijacking" this 7 year old topic.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.21 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.