Brad m
Brad m

Reputation: 97

Error: ER_BAD_FIELD_ERROR: Unknown column 'kappa' in 'where clause'

I keep getting the following error code

Error: ER_BAD_FIELD_ERROR: Unknown column 'kappa' in 'where clause'

when executing this script in nodejs

connection.query('SELECT balance FROM members WHERE username = kappa', function(err, data) {
        if (!err)
         console.log(data);
        else
         console.log(err);

    });

im unsure why this is happening, is my syntax wrong or something?

Upvotes: 1

Views: 13190

Answers (3)

Titan XP
Titan XP

Reputation: 409

You can always try the same codes in MySQL Workbench, it will tell the same error.

SELECT balance FROM members WHERE username = kappa
// Error Code: 1054. Unknown column 'kappa' in 'where clause'

SELECT balance FROM members WHERE username = "kappa"
// No error for this codes.

Upvotes: 0

Ugi Ispoyo Widodo
Ugi Ispoyo Widodo

Reputation: 1

Try this:

SELECT balance FROM members WHERE username = "'+kappa+'"

Upvotes: -2

Mayank Pandeyz
Mayank Pandeyz

Reputation: 26298

For comparing with strings use single quotes like:

"SELECT balance FROM members WHERE username = 'kappa'"

try with this query.

Upvotes: 7

Related Questions