AKP
AKP

Reputation: 1

MYSQL getting 'column not found: 1054 Unknown column' error

firstly, selecting data from table using this query:

SELECT * FROM users WHERE user_id=102030;
{
  "user_id": 102030,
  "social_id": null,
  "user_name": "user_734747",
  "full_name": null,
  "email": null,
  "phone": "1234567890",
  "profile_image": null,
  "referral_code": "rbNqMtqL",
  "created_at": "2022-11-06 10:22:36"
}

this is the JSON format of the result

Problem

When executing another statement:

SELECT * FROM users WHERE referral_code="rbNqMtqL";

it is throwing an error

Column not found: 1054 Unknown column 'rbNqMtqL' in 'where clause

actually, sql replacing this referral_code column with it's previous value

How to fix this issue?

Upvotes: 0

Views: 180

Answers (1)

Tim Biegeleisen
Tim Biegeleisen

Reputation: 521008

I'm actually surprised that your query didn't work. But in any case, what is happening is that the double quotes on the RHS of the WHERE clause are being interpreted as a column name. To fix this, use single quotes:

SELECT * FROM users WHERE referral_code = 'rbNqMtqL';

Upvotes: 1

Related Questions