dataaccess: Fix wrong keyword for initial on-clause.

When specifying an initial on-clause it would detect the storage
variable being non-empty, because it contains the JOIN clause
and use an AND instead of the ON keyword.
Add additional checks to support this case properly.