0

I don't know why I can't use where clause in this project, it shows up throwing Error Code: 1054.

in this case :Error Code: 1054. Unknown column '15/05/20' in 'where clause'

select * from covid_19_india;

select `state/unionterritory`,  
        cured, cured, confirmed, 
        round(deaths/confirmed)*100 as mortality_rate
from covid_19_india
where date = `15/05/20`;

Here is the file I have imported data from the below file...

enter image description here

t.niese
  • 39,256
  • 9
  • 74
  • 101
GIRIXH
  • 53
  • 8
  • 3
    Consider storing dates using a date data type – Strawberry May 17 '20 at 07:39
  • 1
    If the data type is DATE better use Standard SQL compliant *date literals*: `DATE `2020-05-15` which requires a YYYY-MMD-D format and avoids ambiguity. – dnoeth May 17 '20 at 07:46

2 Answers2

1

try the following, put date between ' ' as single quote is the delimiter for the string and it denotes textual data.

Backticks and regular quotes have different meanings in SQL. Quotes (single or double) indicate a literal string, whereas backticks are quoted identifiers.

select `state/unionterritory`,  
        cured, cured, confirmed, 
        round(deaths/confirmed)*100 as mortality_rate
from covid_19_india
where date = '15/05/20';
zealous
  • 7,336
  • 4
  • 16
  • 36
  • `try the following` is not a helpful explanation. Instead of wiring that, you should explain **why** it has to be changed. – t.niese May 17 '20 at 07:35
1

You use backticks ` to quote your 15/05/20, and as of that it becomes an identifier, and is not handled as value. So the database is looking for the column with the name 15/05/20 (like with your state/unionterritory column)

You need to change the quoted to ' (where date = '15/05/20')

t.niese
  • 39,256
  • 9
  • 74
  • 101
  • 2
    ... or even better change it to single quotes (`'`), the SQL standard way for enclosing literals, hence providing more compatibility with other DBMS... – sticky bit May 17 '20 at 07:40