Search code examples
c#sqlitewindows-phone-8

SQLite database select query from multiple tables for windows phone


Trying to develop a Windows phone 8.0 Store App.I need to retrieve records from a sqlite database which are having two tables so far i did not found any tutorial for it .here is what i am doing for get data from one table

var retrievedTasks = dbConn.Query<MMain>("SELECT MMain.ID,           MMain.Name, health.age
FROM MMain INNER JOIN health ON MMain.key = health.key
where MMain.ID = 1" ).FirstOrDefault();  

but i want to achieve this to get data from two tables

       foreach (var rr in retrievedTasks)
        { 

         //how to fetch data from health class table 
        } 

so how to do this and than how to fetch Data from it

he


Solution

  • Your query looks wrong (one extra comma and you should use INNER join with the relevant ON clause)

    SELECT MMain.ID, MMain.Name, health.age
    FROM MMain INNER JOIN health ON MMain.key = health.key
    where MMain.ID = 1
    

    Apart that, I don't see the pb.