Search code examples
javaandroidsqlitecursorandroid-sqlite

SQLite selecting all from multiple tables and reading from cursor


I have a query which retrieves data from different tables

select * from customer c, order o where c.id = o.pID 

both tables have a column 'date_created' and i want to retrieve the date_created from order table

I tried Cursor c = db.execute(sql); String dateCreated = c.getString("date_created") which returned the customer date and not the order date. when i try c.getString("o.date_created") my app crashes and returns "E/SQLiteCursor: requesting column name with table name -- o.date_created java.lang.Exception"

can someone please guide me on how i can get the order date_created? I


Solution

  • How about this:

    select *, c.date_created as customer_date_created, o.date_created as order_date_created from customer c, order o where c.id = o.pID
    

    then just use:

    c.getString("order_date_created");