unknown column in where clause

(*-*)浩
Release: 2019-07-30 10:00:42
Original
24968 people have browsed it

Anyone who has written SQL statements has probably encountered problems similar to Unknown column ‘xxx’ in ‘where clause’. Reading it literally, we can easily conclude that the listing does not exist. This shows that the SQL statement is incorrectly written and needs to be checked and modified.

unknown column in where clause

However, many times it is not caused by an error in the column name. (Recommended study:MySQL video tutorial)

It is caused by not using quotation marks for character type data when piecing together the sql statement.

Example:

String sql="select age from user where name="+xxx+";
Copy after login

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

Unknown column ′xxx′ in ′where clause′
Copy after login

Solution steps :

If name is an integer in SQL, no error will occur, but if the string type in SQL must be enclosed in quotation marks.

So modify the sql to

String sql="select age from user where name=′"+xxx+"′";
Copy after login

and the error will disappear.

For more MySQL related technical articles, please visit theMySQL Tutorialcolumn to learn!

The above is the detailed content of unknown column in where clause. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!