Fischer asked this 8 years ago

SELECT 1 SQL statement

Whats the meaning of SELECT 1 SQL statement?

I have come across this sql

select * from category where exists ( select (1) from products where category.id = products.id )


Vikas 8 years ago
3 likes

Select 1 is used when you want to check the existence of a row in a table and not bothered about its contents.

In your SQL statement you are selecting all categories that has atleast one product.