Leonardo Amigoni
Leonardo Amigoni

Reputation: 2317

Problem with SQLite Statement

I am having problems with the following statement.

SELECT * FROM favorites WHERE personID = 1 HAVING category = "Music"

I am trying to get all the items of Category "Music" where there is "personID" of 1.

Thanks for your help.

Upvotes: 0

Views: 82

Answers (2)

Frank Schmitt
Frank Schmitt

Reputation: 30765

As already mentioned by SeventotheSeven, you cannot use HAVING without a GROUP BY.

From your question, I guess you really need a simple AND:

SELECT * FROM favorites 
WHERE personID = 1 
AND category = 'Music'

Please also note that SQL uses single quotes around strings, not double quotes.

Upvotes: 4

SeventotheSeven
SeventotheSeven

Reputation: 386

HAVING has to be used with a GROUP BY clause.

Upvotes: 1

Related Questions