执行SQL DELETE查询遇#1054错误:WHERE子句未知列‘Fever’
Hey there! I see you're building your Diseases Detection Management System with MAMP and phpMyAdmin, and hit a snag when trying to run a DELETE query. Let's figure out what's going wrong and fix it right away.
What's Causing the Error?
The #1054 - Unknown column 'Fever' in 'where clause' error happens because MySQL is misreading your condition. Look at your original query:
DELETE FROM `disease_information` WHERE `Disease_name`=`Fever`
You used backticks (`) around Fever. In SQL, backticks are only for wrapping column or table names (like when your column has a space or conflicts with a SQL keyword). When you wrap a string value like Fever in backticks, MySQL thinks you're referring to a column named Fever—which doesn't exist in your table, hence the error.
The Corrected Query
String values need to be enclosed in single quotes ('), not backticks. Here's the fixed version:
DELETE FROM `disease_information` WHERE `Disease_name`='Fever'
Now MySQL understands that Fever is a value to match against the Disease_name column, not a column itself.
Quick Tips to Avoid This Down the Line
- Backticks vs Single Quotes: Stick to backticks only for table/column identifiers, and single quotes for string values.
- Verify Before Deleting: Always run a SELECT first to confirm you're targeting the right records:
This prevents accidental deletion of the wrong data!SELECT * FROM `disease_information` WHERE `Disease_name`='Fever' - Safe Queries for Apps: If this is part of a PHP application (not just phpMyAdmin), use prepared statements instead of string concatenation to build queries. This avoids syntax errors and protects against SQL injection.
内容的提问来源于stack exchange,提问作者AMINA ARSHAD

