Results 1 to 4 of 4

Thread: Need help with a query

  1. #1
    Join Date
    Oct 2010
    Posts
    1

    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

  2. #2
    Join Date
    Jan 2010
    Posts
    37
    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.

  3. #3
    Join Date
    Nov 2010
    Posts
    3
    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.

  4. #4
    Join Date
    Dec 2009
    Posts
    4

    Smile

    select name from <tbl_name> where <column_name> like '%Bank%';

    <apostrophe key is enough

    `backquote` denotes column>

    Thanks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •