Get the App
SLTechnology News&Howtos  ›  Database  › 

How to solve the problem of unknown column in where clause

Shulou Source: shulou.com Published: 2022-06-01 01:59:42 09月30日 Update

The editor will share with you how to solve the problem of unknown column in where clause. I hope you will gain a lot after reading this article. Let's discuss it together.

Anyone who has written a sql statement may have encountered a problem similar to Unknown column 'xxx' in' where clause'. If we take it literally, we can easily come to the conclusion that the listing does not exist. This shows that the sql statement is not written correctly and needs to be checked and modified.

However, in many cases, the start is not caused by a column name error.

It is caused by the lack of quotation marks around the character type data when piecing together the sql statement.

Example:

String sql= "select age from user where name=" + xxx+ "

Set the value of name to columName, the error is as follows:

Unknown column 'xxx' in' where clause'

Resolution steps:

There will be no error in sql if name is an integer, and if the string type in sql must be enclosed in quotation marks.

So change the sql to

String sql= "select age from user where name='" + xxx+ "'"

The error disappears.

After reading this article, I believe you have a certain understanding of how to solve the problem of unknown column in where clause, want to know more about it, welcome to follow the industry information channel, thank you for reading!

Tags: Questions statements errors characters quotation marks articles types examples strings literals done data time more useful steps knowledge conclusions but industry Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno NVidia Shulou Information Shulou Technology Huawei Microsoft