This has happened couple times, already, so I may as well blog about it. If you use Views in Drupal, you already know that it shows you the final SQL generated. Very useful feature, but there’s a rare edge condition when the SQL returns results (if you run it from an SQL client), but Views shows zero elements. Extremely frustrating and confusing.

How can this happen?

The thing is, Views omits limit condition when displaying the SQL, so when you copy/paste your SQL in a client you are not running exactly the thing that Views displays.

Solution: check the pagination setting in the View settings. Most of the time the problem is an offset value indicated that is higher than number of elements in the result-set.