0

I am currently doing a query such as

"SELECT * FROM MyTable WHERE SomeValue=0"

There are cases where this does not exist. Is there a method for determining if the select actually found the data without checking that each returned value is empty?

1 Answer 1

1

the data without checking that each returned value is empty?

If there are no rows matching the criteria, then no result set or table would be returned. So, there is no need for this.

You can use the IF EXISTS (Select Query) to see if there were any results matching the criteria and perform your subsequent operations.

Sign up to request clarification or add additional context in comments.

5 Comments

I have a repeatable situation when I perform a select on a value that does not exist in the database, then call mysql_num_rows and it does not return 0. What am I missing here?
mysql_real_query also returns 0 (not error) when performing a select where the value does not exist.
MySQL wouldn't throw an error if there are no matches to a given filter. So, the behavior of MySQL is correct and expected. Checking on the PHP equivalent of no results found for query in mysql...
From this manual page at php.net/manual/en/function.mysql-num-rows.php, it seems mysql_num_rows should be 0 if there are no matching records for a query. Not sure why it's not 0 in your case :(
Hmm, well maybe I'm messing up somehow. I'll dig into it more. Thanks for the help :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.