Mark Hollis
Mark Hollis

Reputation: 151

WHERE clause returning no results

I have the following query:

SELECT * 
FROM public."Matches"
WHERE 'Matches.Id' = '24e81894-2f1e-4654-bf50-b75e584ed3eb'

I'm certain there is an existing match with this Id (tried it on other Ids as well), but it returns 0 rows. I'm new to querying with PgAdmin so it's probably just a simple error, but I've read the docs up and down and can't seem to find why this is returning nothing.

Upvotes: 0

Views: 459

Answers (1)

user330315
user330315

Reputation:

Single quotes are only used for strings in SQL. So 'Matches.Id' is a string constant and obviously not the same as '24e81894-2f1e-4654-bf50-b75e584ed3eb' thus the WHERE condition is always false (it's like writing where 1 = 0)

You need to use double quotes for identifiers, the same way you did in the FROM clause.

WHERE "Matches"."Id" = ...

In general the use of quoted identifiers is strongly discouraged.

Upvotes: 3

Related Questions