I’m trying to access multiple tables as a single view but I’m not matching any data in my queries. I am fairly certain that the problem lies in the view declaration.
CREATE VIEW IF NOT EXISTS method_view
AS SELECT
peercreateddata.id,
peercreateddata.name,
peercreateddata.shared,
peercreateddata.authorHash,
peercreateddata.creationDate,
peercreateddata.firstSeen,
peercreateddata.lang,
methods.primaryMatch,
methods.methodHash,
methods.methodbyline,
methods.methodexpirationDate,
methods.methodlocation,
localResources.localmimeType,
remoteResources.remotemimeType,
remoteResources.remotelocation
FROM peercreateddata peercreateddata,
methods methods,
localResources localResources,
remoteResources remoteResources
WHERE (methods.peerDataId = peercreateddata.id)
AND (localResources.localMethodId = methods.id)
AND (remoteResources.remoteMethodId = methods.id) ;
Looking at the WHERE clause, methods.peerDataId always matches a single value of peercreateddata.id. The tables localResources and remoteResources are sometimes empty, sometimes do not contain matches to the query, and sometimes contain multiple matches.
I am developing for Android. The syntax passes a validator (although some complaints about using a field called ‘name’).
Use inner and outer join clauses. See the docs.
Replace your from clause with this and get rid of the where