Return just the first result of mysql Query
You can use EXISTS
as such:
SELECT EXISTS(SELECT 1 FROM foo_table WHERE foo=<foo_id>)
.
The SELECT is ignored as EXISTS only checks the WHERE clause. As it is good practice to avoid using *
, it is substituted by 1
here.
Here is the Documentation.