0

I have 2 tables consisting of Table 1 Person: age_id(PK) and treatment, Table 2 genders: age_id(FK) and age

SELECT COUNT(genders.gender_id) AS count, genders.gender
FROM genders JOIN Person on genders.gender_id = Person.gender 
WHERE Person.treatment = “Yes”
GROUP BY genders.gender;

I am trying to display the number of people according to gender that has received treatment using JOIN and WHERE but am faced with this error. The Treatment column consists of rows with either "Yes" or "No" but somehow the WHERE condition is not detecting it, what am I doing wrong?

Shadow
  • 33,525
  • 10
  • 51
  • 64
Ronald
  • 17
  • 4
  • 1
    This should answer your question: https://stackoverflow.com/questions/1992314/what-is-the-difference-between-single-and-double-quotes-in-sql – Kevin Dec 27 '22 at 07:44
  • i tried changing to single quotes and faced the same issue – Ronald Dec 27 '22 at 07:51
  • Looks like you might be copying and pasting from a document that converts quotes into curly quotes. Try typing the quote directly into your query not copying and pasting. – scotru Dec 27 '22 at 07:53
  • These quotes are not even ascii double quotes. They are Left Double Quotation Mark(U+201C). Use regular ascii single quotes for string literals. – forpas Dec 27 '22 at 07:54
  • oh, I didn't realize that transferring my code from google docs to MySQL would cause the quotes to convert, thanks so much! – Ronald Dec 27 '22 at 07:58

1 Answers1

0

Try this :

SELECT COUNT(genders.gender_id) AS count, genders.gender
FROM genders JOIN Person on genders.gender_id = Person.gender 
WHERE Person.treatment = 'Yes'
GROUP BY genders.gender;

Use single quote instead of double quotes

Single quotes are for Strings Literals (date literals are also strings); Double quotes are for Database Identifiers;

SelVazi
  • 10,028
  • 2
  • 13
  • 29