Hello Community
Hope to get some pointers here because i have a hit a snag!
I have 4 tables.
Meters:_id, SerialNumber
Tenants: _id, FirstName.
TenantsMeters: _id,Tenant_id,Meter_id, (basically junction table for linking
many to many relationship btn tenants and meters)
MeterReading: _id, ReadingDate, Reading, TenantMeter_id(FK for TenantMeters
table)
This query works in sqlite manager
*SELECT M._id as Meter_id, M.MeterNumber, R1.ReadingDate as ReadingDate,
R1.Reading AS CurrentReading, R2.ReadingDate AS PrevReadingDate, R2.Reading
AS PrevMeterReading, R2.Rate as Rate, R2._id as _id,R1.TenantMeter_id
FROM (Meters AS M INNER JOIN TenantMeters ON M._id = TenantMeters.Meter_id)
INNER JOIN (MeterReading AS R1 INNER JOIN MeterReading AS R2 ON
R1.TenantMeter_id = R2.TenantMeter_id) ON TenantMeters._id =
R1.TenantMeter_id
WHERE (((R2.ReadingDate)=(SELECT Max(R3.ReadingDate)
FROM [MeterReading] AS R3
WHERE (R3.TenantMeter_id = R1.TenantMeter_id)
AND (R3.ReadingDate < R1.ReadingDate)
))) OR (((R2.TenantMeter_id) Is Null))
*
But fails in sqlite database in android with the error "no such
column:R1.ReadingDate"
It fails in android app and also fails when i connect to the android sqlite
db from command prompt .
What can be the likely cause?
Any pointers please.
Ronald
--
View this message in context:
http://sqlite.1065341.n5.nabble.com/Query-executes-in-sqlite-manager-but-not-sqlite-database-in-android-tp73466.html
Sent from the SQLite mailing list archive at Nabble.com.
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users