Bfrank
Bfrank

Reputation: 33

error code: 1054. Unknown column "x" in 'field list'

so I'm posting on behalf of someone since I have a stack account and they do not. Saying that, I do not know much about SQL, simply posting this question from her mouth to this.

Selecting the code from #1 --

create table employee


(
FNAME varchar(100) NOT NULL,
MINIT char(1),
LNAME varchar(100) NOT NULL,
SSN int NOT NULL,
BDATE date NOT NULL,
ADDRESS varchar(150),
SEX char(1) NOT NULL,
SALARY decimal(10,2) NOT NULL,
SUPERSSN int NULL,
DNO int null,

PRIMARY KEY (SSN),
INDEX (SSN)
)
;

use employee;

--#1
select BDate, Address from employee
where FNAME='John' and MINIT='B' and LNAME='Smith';

throws the error code 1054 saying "Unknock column, 'BDate' in 'field list'"

Can anyone point her in the right direction? Any help would be appreciated. If needed, I can post the entire database code.

Upvotes: 0

Views: 3716

Answers (2)

Marco Bernardini
Marco Bernardini

Reputation: 705

Your table is created with the column ADDRESS, while your query is trying to locate the column Address.

Of course they are not the same thing, so you have an error.

Same for the column BDATE.

Correction

MySql is case insensitive (checked just now on my 5.5.40), but it returns the row with the same case used for the query, so I think it's preferable to keep some consistency between PHP and MySql: PHP variables are case sensitive.

Upvotes: 0

Ace McCloud
Ace McCloud

Reputation: 900

Use employee refers to another database with (probably) another employee table in it (which has different fields) . Please remove the use and try again. Check which database you created the above employee table. Use is used to refer to databases not tables.

Upvotes: 1

Related Questions