-
Need help with a query
Hello
I have this table named works:
Code:
employeeName companyName salary
Brian Jørgensen First Bank Corporation 600000
Joe Santana First Bank Corporation 500000
Kim Wild First Bank Corporation 400000
Gino Mohammed We Do PHP 100000
Søren Petersen We Do PHP 300000
Hanne Jørgensen We Do PHP 100000
John Rambo We Do PHP 20000
Mathias Hansen All Of Java 150000
I want to find the names of all employees who work for First Bank Corporation.
For this i made this query in mysql:
SELECT `employeeName`
FROM `mhha_Assignment2`.`works`
WHERE `companyName` LIKE `First Bank Corporation`;
I get this error:
Error Code: 1054
Unknown column 'First Bank Corporation' in 'where clause'
Can anyone explain me what is wrong?
Thanks
-
The error sounds like you are trying to reference 'First Bank Corporation' as the column name and not the value you want to filter on. Without knowing more it is hard to troubleshoot. You posted what you stated was the code for the works table, but that is just a result set. Can you post the table definition?
Also, I am not very familiar with mySQL, but do you always have to put the backticks (`) everywhere to encase both your object names and values? That seems a bit strange. I just wanted to make sure.
-
Try this :
SELECT employeeName
FROM works
WHERE companyName LIKE '%Bank%';
to get all records that contain Bank in the companyName
or this :
SELECT employeeName
FROM works
WHERE companyName LIKE 'First Bank Corporation';
to be more specific.
-
select name from <tbl_name> where <column_name> like '%Bank%';
<apostrophe key is enough
`backquote` denotes column>
Thanks