Skip to content
Advertisement

What does it mean SELECT EXISTS (SELECT 1 FROM favoritelist WHERE id=:id)

What is the meaning of SELECT EXISTS (SELECT 1 FROM favoritelist WHERE id=:id) in:

Advertisement

Answer

The exists condition evaluates whether at least one row exists in favoritelist where id matches the given parameter. The outer query evaluates the condition in numeric context, and returns 1 if the condition is satisfied, else 0.

In a nutshell:

  • if at least one record exists in favoritelist whose id matches the parameter, the query returns 1

  • else, it returns 0

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement